Changeset 4099
- Timestamp:
- 02/17/09 21:48:49 (4 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
install_scripts/windows/setup.py (modified) (1 diff)
-
umit_scheduler.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/install_scripts/windows/setup.py
r4090 r4099 167 167 zipfile = None, 168 168 cmdclass = {"py2exe": umit_py2exe}, 169 service = [ 'umit_scheduler'],169 service = [{'modules': ['umit_scheduler'], 'cmdline_style': 'custom'}], 170 170 windows = [{ 171 171 "script": "umit", -
trunk/umit_scheduler.py
r4088 r4099 40 40 HOME_CONF = None 41 41 RUNNING_FILE = None 42 42 if hasattr(sys, 'frozen'): 43 FROZEN_CFG = os.path.join(os.path.dirname(sys.path[0]), ".scheduserhome") 44 else: 45 FROZEN_CFG = None 43 46 44 47 class UMITSchedulerWinService(WindowsService): … … 46 49 _svc_display_name_ = "%s service" % _svc_name_ 47 50 _svc_description_ = _svc_display_name_ 48 _exe_args_ = None # This is defined at bottom 51 _exe_args_ = None # This is defined at bottom (when not using py2exe) 49 52 50 53 def __init__(self, args): … … 53 56 def run(self): 54 57 # _exe_args_ will be our sys.argv when this runs as a Windows service 55 Scheduler.main('start', winhndl=self.hndl_waitstop, *sys.argv[1:]) 58 # as long as we don't run under py2exe. 59 if FROZEN_CFG is not None: 60 cfg = open(FROZEN_CFG, 'r') 61 home_path = cfg.read() 62 cfg.close() 63 args = (sys.path[0], home_path) 64 else: 65 args = sys.argv[1:] 66 Scheduler.main('start', winhndl=self.hndl_waitstop, *args) 56 67 57 68 … … 72 83 Show help 73 84 """ 74 try:75 program_name = __file__76 except AttributeError:77 if hasattr(sys, 'frozen'):78 program_name = sys.executable79 else:80 program_name = sys.argv[0]81 85 print (_("Usage:") + 82 (" %s start|stop|cleanup|running <config_dir>" % program_name))86 (" %s start|stop|cleanup|running <config_dir>" % __file__)) 83 87 84 88 … … 106 110 return 1 107 111 108 if __name__ == "__main__": 112 113 def pre_main(): 109 114 if len(sys.argv) < 2 or len(sys.argv) > 3: 110 115 usage() 111 sys.exit(0)116 return 0 112 117 113 118 if CONFIG_DIR: # forcing especified dir … … 119 124 setup_homedir(os.path.join(os.path.expanduser("~"), '.umit')) 120 125 121 sys.exit(main(sys.argv[1:])) 126 return main(sys.argv[1:]) 127 128 129 if FROZEN_CFG is not None: 130 def write_frozen_cfg(): 131 setup_homedir(os.path.join(os.path.expanduser('~'), '.umit')) 132 conf = open(FROZEN_CFG, 'w') 133 conf.write(HOME_CONF) 134 conf.close() 135 136 import win32serviceutil 137 # HandleCommandLine is used by py2exe when defining a service with 138 # cmdline_style as 'custom' 139 def HandleCommandLine(): 140 # XXX I will need the user home before starting the Scheduler, 141 # I wish changing UMITSchedulerWinService._exe_args_ would work 142 # here too, but it doesn't. The workaround here is far from 143 # ideal. 144 if sys.argv[1] == 'install': 145 write_frozen_cfg() 146 elif sys.argv[1] in ('start', 'debug'): 147 if not os.path.isfile(FROZEN_CFG): 148 write_frozen_cfg() 149 150 win32serviceutil.HandleCommandLine(UMITSchedulerWinService) 151 152 if __name__ == "__main__": 153 sys.exit(pre_main())
