fixed winservice problem
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.3.0 (2012-12-09 14:28:45) rc1
|
||||
Version 2.3.0 (2012-12-10 21:31:49) rc1
|
||||
|
||||
+5
-3
@@ -34,7 +34,7 @@ try:
|
||||
import Tkinter
|
||||
import tkMessageBox
|
||||
import contrib.taskbar_widget
|
||||
from winservice import web2py_windows_service_handler
|
||||
from winservice import register_service_handler, Web2pyService
|
||||
have_winservice = True
|
||||
except:
|
||||
have_winservice = False
|
||||
@@ -1116,8 +1116,10 @@ def start(cron=True):
|
||||
if options.winservice:
|
||||
if os.name == 'nt':
|
||||
if have_winservice:
|
||||
web2py_windows_service_handler(['', options.winservice],
|
||||
options.config)
|
||||
register_service_handler(
|
||||
argv=['', options.winservice],
|
||||
opt_file=options.config,
|
||||
cls=Web2pyService)
|
||||
else:
|
||||
print 'Error: Missing python module winservice'
|
||||
sys.exit(1)
|
||||
|
||||
+7
-8
@@ -191,22 +191,21 @@ class Web2pyCronService(Web2pyService):
|
||||
if self.extcron:
|
||||
self.extcron.join()
|
||||
|
||||
def register_service_handler(
|
||||
name=Web2pyService, argv=None, opt_file='options'):
|
||||
def register_service_handler(argv=None, opt_file='options', cls=Web2pyService):
|
||||
path = os.path.dirname(__file__)
|
||||
web2py_path = up(path)
|
||||
if web2py_path.endswith('.zip'): # in case bianry distro 'library.zip'
|
||||
web2py_path = os.path.dirname(web2py_path)
|
||||
os.chdir(web2py_path)
|
||||
classstring = os.path.normpath(
|
||||
os.path.join(web2py_path, 'gluon.winservice.'+name.__name__))
|
||||
os.path.join(web2py_path, 'gluon.winservice.'+cls.__name__))
|
||||
if opt_file:
|
||||
name._exe_args_ = opt_file
|
||||
cls._exe_args_ = opt_file
|
||||
win32serviceutil.HandleCommandLine(
|
||||
name, serviceClassString=classstring, argv=['', 'install'])
|
||||
cls, serviceClassString=classstring, argv=['', 'install'])
|
||||
win32serviceutil.HandleCommandLine(
|
||||
name, serviceClassString=classstring, argv=argv)
|
||||
cls, serviceClassString=classstring, argv=argv)
|
||||
|
||||
if __name__ == '__main__':
|
||||
register_service_handler(Web2pyService)
|
||||
register_service_handler(Web2pyCronService)
|
||||
register_service_handler(cls=Web2pyService)
|
||||
register_service_handler(cls=Web2pyCronService)
|
||||
|
||||
Reference in New Issue
Block a user