CraftLaunch APIリファレンス

clnch_main.py

00001 import os
00002 import sys
00003 import getopt
00004 import shutil
00005 
00006 import cterm
00007 
00008 import clnch
00009 import clnch_ini
00010 import clnch_misc
00011 import clnch_threadutil
00012 
00013 #--------------------------------------------------------------------
00014 
00015 debug = False
00016 profile = False
00017 
00018 option_list, args = getopt.getopt( sys.argv[1:], "dp" )
00019 for option in option_list:
00020     if option[0]=="-d":
00021         debug = True
00022     elif option[0]=="-p":
00023         profile = True
00024 
00025 #--------------------------------------------------------------------
00026 
00027 if __name__ == "__main__":
00028 
00029     # 多重起動を抑制
00030     clnch_wnd = clnch_misc.findExistingClnchWindow()
00031     if clnch_wnd:
00032         print "another CraftLaunch instance already exists."
00033         clnch_wnd.restore()
00034         clnch_wnd.getLastActivePopup().setForeground(False)
00035         if clnch_wnd.isEnabled():
00036             clnch_wnd.setActive()
00037         sys.exit(0)
00038 
00039     cterm.registerWindowClass( u"Clnch" )
00040 
00041     sys.path[0:0] = [
00042         os.path.join( os.path.split(sys.argv[0])[0], 'extension' ),
00043         os.path.join( os.path.split(sys.argv[0])[0], 'script' ),
00044         ]
00045 
00046     default_config_filename = os.path.join( os.path.split(sys.argv[0])[0], '_config.py' )
00047     config_filename = os.path.join( os.path.split(sys.argv[0])[0], 'config.py' )
00048 
00049     if not os.path.exists(config_filename) and os.path.exists(default_config_filename):
00050         shutil.copy( default_config_filename, config_filename )
00051 
00052     clnch_ini.read()
00053 
00054     clnch_threadutil.JobQueue.createDefaultQueue()
00055 
00056     _main_window = clnch.MainWindow(
00057         config_filename = config_filename,
00058         debug=debug,
00059         profile=profile )
00060 
00061     clnch.initTemp(_main_window)
00062 
00063     _main_window.configure()
00064 
00065     _main_window.start()
00066 
00067     _main_window.topLevelMessageLoop()
00068 
00069     _main_window.stop()
00070 
00071     _main_window.saveState()
00072 
00073     clnch.JobQueue.cancelAll()
00074 
00075     clnch.destroyTemp(_main_window)
00076 
00077     _main_window.destroy()
00078 
00079     clnch.JobQueue.joinAll()
00080 
00081     clnch_ini.write()    

Copyright © 2009 craftware. All rights reserved.