equal
deleted
inserted
replaced
53 confnodesroot.logger.write(_("PYRO connecting to URI : %s\n") % uri) |
53 confnodesroot.logger.write(_("PYRO connecting to URI : %s\n") % uri) |
54 |
54 |
55 scheme, location = uri.split("://") |
55 scheme, location = uri.split("://") |
56 if scheme == "PYROS": |
56 if scheme == "PYROS": |
57 import connectors.PYRO.PSK_Adapter |
57 import connectors.PYRO.PSK_Adapter |
|
58 _unused_module_imported_for_monkey_patching_pylint_sucks = connectors.PYRO.PSK_Adapter |
58 schemename = "PYROLOCPSK" |
59 schemename = "PYROLOCPSK" |
59 url, ID = location.split('#') #TODO fix exception when # not found |
60 url, ID = location.split('#') # TODO fix exception when # not found |
60 # load PSK from project |
61 # load PSK from project |
61 secpath = os.path.join(str(confnodesroot.ProjectPath), 'psk', ID+'.secret') |
62 secpath = os.path.join(str(confnodesroot.ProjectPath), 'psk', ID+'.secret') |
62 if not os.path.exists(secpath): |
63 if not os.path.exists(secpath): |
63 confnodesroot.logger.write_error( |
64 confnodesroot.logger.write_error( |
64 'Error: Pre-Shared-Key Secret in %s is missing!\n' % secpath) |
65 'Error: Pre-Shared-Key Secret in %s is missing!\n' % secpath) |
71 schemename = "PYROLOC" |
72 schemename = "PYROLOC" |
72 |
73 |
73 # Try to get the proxy object |
74 # Try to get the proxy object |
74 try: |
75 try: |
75 RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject") |
76 RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject") |
76 except Exception: |
77 except Exception, e: |
77 confnodesroot.logger.write_error(_("Connection to '%s' failed with exception '%s'\n") % (location, str(e))) |
78 confnodesroot.logger.write_error( |
78 #confnodesroot.logger.write_error(traceback.format_exc()) |
79 _("Connection to {loc} failed with exception {ex}\n").format( |
|
80 loc=location, exo=str(e))) |
79 return None |
81 return None |
80 |
82 |
81 RemotePLCObjectProxy.adapter.setTimeout(60) |
83 RemotePLCObjectProxy.adapter.setTimeout(60) |
82 |
84 |
83 def PyroCatcher(func, default=None): |
85 def PyroCatcher(func, default=None): |
106 # lambda is for getattr of GetPLCstatus to happen inside catcher |
108 # lambda is for getattr of GetPLCstatus to happen inside catcher |
107 IDPSK = PyroCatcher(RemotePLCObjectProxy.GetPLCID)() |
109 IDPSK = PyroCatcher(RemotePLCObjectProxy.GetPLCID)() |
108 if IDPSK is None: |
110 if IDPSK is None: |
109 confnodesroot.logger.write_warning(_("PLC did not provide identity and security infomation.\n")) |
111 confnodesroot.logger.write_warning(_("PLC did not provide identity and security infomation.\n")) |
110 else: |
112 else: |
111 ID,secret = IDPSK |
113 ID, secret = IDPSK |
112 PSK.UpdateID(confnodesroot.ProjectPath, ID, secret, uri) |
114 PSK.UpdateID(confnodesroot.ProjectPath, ID, secret, uri) |
113 |
|
114 |
115 |
115 _special_return_funcs = { |
116 _special_return_funcs = { |
116 "StartPLC": False, |
117 "StartPLC": False, |
117 "GetTraceVariables": (PlcStatus.Broken, None), |
118 "GetTraceVariables": (PlcStatus.Broken, None), |
118 "GetPLCstatus": (PlcStatus.Broken, None), |
119 "GetPLCstatus": (PlcStatus.Broken, None), |