Beremiz_service.py
changeset 2324 1cf3768ebf85
parent 2323 33a0dbabccd3
child 2429 15f18dc8b56a
equal deleted inserted replaced
2323:33a0dbabccd3 2324:1cf3768ebf85
    76 
    76 
    77 # default values
    77 # default values
    78 interface = ''
    78 interface = ''
    79 port = 3000
    79 port = 3000
    80 webport = 8009
    80 webport = 8009
    81 pskpath = None
    81 PSKpath = None
    82 wampconf = None
    82 wampconf = None
    83 servicename = None
    83 servicename = None
    84 autostart = False
    84 autostart = False
    85 enablewx = True
    85 enablewx = True
    86 havewx = False
    86 havewx = False
   118     elif o == "-w":
   118     elif o == "-w":
   119         webport = None if a == "off" else int(a)
   119         webport = None if a == "off" else int(a)
   120     elif o == "-c":
   120     elif o == "-c":
   121         wampconf = None if a == "off" else a
   121         wampconf = None if a == "off" else a
   122     elif o == "-s":
   122     elif o == "-s":
   123         pskpath = None if a == "off" else a
   123         PSKpath = None if a == "off" else a
   124     elif o == "-e":
   124     elif o == "-e":
   125         fnameanddirname = list(os.path.split(os.path.realpath(a)))
   125         fnameanddirname = list(os.path.split(os.path.realpath(a)))
   126         fnameanddirname.reverse()
   126         fnameanddirname.reverse()
   127         extensions.append(fnameanddirname)
   127         extensions.append(fnameanddirname)
   128     else:
   128     else:
   490     execfile(os.path.join(extension_folder, extention_file), locals())
   490     execfile(os.path.join(extension_folder, extention_file), locals())
   491 
   491 
   492 # Service name is used as an ID for stunnel's PSK
   492 # Service name is used as an ID for stunnel's PSK
   493 # Some extension may set 'servicename' to a computed ID or Serial Number
   493 # Some extension may set 'servicename' to a computed ID or Serial Number
   494 # instead of using commandline '-n'
   494 # instead of using commandline '-n'
   495 if servicename is not None and pskpath is not None:
   495 if servicename is not None and PSKpath is not None:
   496     from runtime.Stunnel import ensurepsk
   496     from runtime.Stunnel import ensurePSK
   497     ensurepsk(servicename, pskpath)
   497     ensurePSK(servicename, PSKpath)
   498 
   498 
   499 runtime.CreatePLCObjectSingleton(
   499 runtime.CreatePLCObjectSingleton(
   500     WorkingDir, argv, statuschange, evaluator, pyruntimevars)
   500     WorkingDir, argv, statuschange, evaluator, pyruntimevars)
   501 
   501 
   502 pyroserver = Server(servicename, interface, port)
   502 pyroserver = Server(servicename, interface, port)
   515             LogMessageAndException(_("Nevow Web service failed. "))
   515             LogMessageAndException(_("Nevow Web service failed. "))
   516 
   516 
   517     if havewamp:
   517     if havewamp:
   518         try:
   518         try:
   519             WC.SetServer(pyroserver)
   519             WC.SetServer(pyroserver)
   520             WC.RegisterWampClient(wampconf, pskpath)
   520             WC.RegisterWampClient(wampconf, PSKpath)
   521             WC.RegisterWebSettings(NS)
   521             WC.RegisterWebSettings(NS)
   522         except Exception:
   522         except Exception:
   523             LogMessageAndException(_("WAMP client startup failed. "))
   523             LogMessageAndException(_("WAMP client startup failed. "))
   524 
   524 
   525 pyro_thread_started = Lock()
   525 pyro_thread_started = Lock()