Beremiz_service.py
changeset 1893 971de876b1af
parent 1889 baff54446535
child 1894 f224383cc883
equal deleted inserted replaced
1892:daf40a1e7607 1893:971de876b1af
    50            -a        - autostart PLC (0:disable 1:enable) (default:0)
    50            -a        - autostart PLC (0:disable 1:enable) (default:0)
    51            -x        - enable/disable wxTaskbarIcon (0:disable 1:enable) (default:1)
    51            -x        - enable/disable wxTaskbarIcon (0:disable 1:enable) (default:1)
    52            -t        - enable/disable Twisted web interface (0:disable 1:enable) (default:1)
    52            -t        - enable/disable Twisted web interface (0:disable 1:enable) (default:1)
    53            -w        - web server port or "off" (default:8009)
    53            -w        - web server port or "off" (default:8009)
    54            -c        - WAMP client config file or "off" (default:wampconf.json)
    54            -c        - WAMP client config file or "off" (default:wampconf.json)
       
    55            -s        - WAMP client secret, given as a file or "off"
    55            -e        - python extension (absolute path .py)
    56            -e        - python extension (absolute path .py)
    56 
    57 
    57            working_dir - directory where are stored PLC files
    58            working_dir - directory where are stored PLC files
    58 """ % sys.argv[0])
    59 """ % sys.argv[0])
    59 
    60 
    68 
    69 
    69 # default values
    70 # default values
    70 given_ip = None
    71 given_ip = None
    71 port = 3000
    72 port = 3000
    72 webport = 8009
    73 webport = 8009
    73 wampconf = "wampconf.json"
    74 wampsecret = None
       
    75 wampconf = None
    74 servicename = None
    76 servicename = None
    75 autostart = False
    77 autostart = False
    76 enablewx = True
    78 enablewx = True
    77 havewx = False
    79 havewx = False
    78 enabletwisted = True
    80 enabletwisted = True
   103         autostart = int(a)
   105         autostart = int(a)
   104     elif o == "-w":
   106     elif o == "-w":
   105         webport = None if a == "off" else int(a)
   107         webport = None if a == "off" else int(a)
   106     elif o == "-c":
   108     elif o == "-c":
   107         wampconf = None if a == "off" else a
   109         wampconf = None if a == "off" else a
       
   110     elif o == "-s":
       
   111         wampsecret = None if a == "off" else a
   108     elif o == "-e":
   112     elif o == "-e":
   109         extensions.append(a)
   113         extensions.append(a)
   110     else:
   114     else:
   111         usage()
   115         usage()
   112         sys.exit()
   116         sys.exit()
   594         except Exception, e:
   598         except Exception, e:
   595             print(_("Nevow Web service failed. "), e)
   599             print(_("Nevow Web service failed. "), e)
   596 
   600 
   597     if wampconf is not None:
   601     if wampconf is not None:
   598         try:
   602         try:
   599             WC.RegisterWampClient(wampconf)
   603             wampconf_project = os.path.join(WorkingDir, "wampconf.json")
   600             pyruntimevars["wampsession"] = WC.GetSession
   604             _wampconf = WC.LoadWampClientConf(wampconf_project) # if project WAMP config is added
   601             WC.SetServer(pyroserver)
   605 
       
   606             if not _wampconf:
       
   607                 # loaded wamp config file path forced parameter -c
       
   608                 _wampconf = WC.LoadWampClientConf(wampconf)
       
   609             else:
       
   610                 wampconf = wampconf_project
       
   611 
       
   612             if _wampconf and _wampconf["url"]:
       
   613                 WC.RegisterWampClient(wampconf, wampsecret)
       
   614                 pyruntimevars["wampsession"] = WC.GetSession
       
   615                 WC.SetServer(pyroserver)
       
   616             else:
       
   617                 print(_("WAMP config is not defined."))
   602         except Exception, e:
   618         except Exception, e:
   603             print(_("WAMP client startup failed. "), e)
   619             print(_("WAMP client startup failed. "), e)
   604 
   620 
   605 
   621 
   606 if havetwisted or havewx:
   622 if havetwisted or havewx: