equal
deleted
inserted
replaced
34 import Pyro |
34 import Pyro |
35 import Pyro.core |
35 import Pyro.core |
36 import Pyro.util |
36 import Pyro.util |
37 from Pyro.errors import PyroError |
37 from Pyro.errors import PyroError |
38 |
38 |
|
39 import PSKManagement as PSK |
39 |
40 |
40 zeroconf_service_type = '_PYRO._tcp.local.' |
41 zeroconf_service_type = '_PYRO._tcp.local.' |
41 # this module attribute contains a list of DNS-SD (Zeroconf) service types |
42 # this module attribute contains a list of DNS-SD (Zeroconf) service types |
42 # supported by this connector confnode. |
43 # supported by this connector confnode. |
43 # |
44 # |
122 IDPSK = PyroCatcher(RemotePLCObjectProxy.GetPLCID)() |
123 IDPSK = PyroCatcher(RemotePLCObjectProxy.GetPLCID)() |
123 if IDPSK is None: |
124 if IDPSK is None: |
124 confnodesroot.logger.write_error(_("Cannot get PLC ID - connection failed.\n")) |
125 confnodesroot.logger.write_error(_("Cannot get PLC ID - connection failed.\n")) |
125 return None |
126 return None |
126 |
127 |
127 if scheme != "PYROS": |
128 ID,secret = IDPSK |
128 ID,PSK = IDPSK |
129 PSK.UpdateID(confnodesroot.ProjectPath, ID, secret, uri) |
129 secdir = os.path.join(str(confnodesroot.ProjectPath), 'psk') |
|
130 if not os.path.exists(secdir): |
|
131 os.mkdir(secdir) |
|
132 secpath = os.path.join(secdir, ID+'.secret') |
|
133 with open(secpath, 'w') as f: |
|
134 f.write(ID+":"+PSK) |
|
135 |
130 |
136 _special_return_funcs = { |
131 _special_return_funcs = { |
137 "StartPLC": False, |
132 "StartPLC": False, |
138 "GetTraceVariables": ("Broken", None), |
133 "GetTraceVariables": ("Broken", None), |
139 "GetPLCstatus": ("Broken", None), |
134 "GetPLCstatus": ("Broken", None), |
143 class PyroProxyProxy(object): |
138 class PyroProxyProxy(object): |
144 """ |
139 """ |
145 A proxy proxy class to handle Beremiz Pyro interface specific behavior. |
140 A proxy proxy class to handle Beremiz Pyro interface specific behavior. |
146 And to put Pyro exception catcher in between caller and Pyro proxy |
141 And to put Pyro exception catcher in between caller and Pyro proxy |
147 """ |
142 """ |
|
143 |
148 def __getattr__(self, attrName): |
144 def __getattr__(self, attrName): |
149 member = self.__dict__.get(attrName, None) |
145 member = self.__dict__.get(attrName, None) |
150 if member is None: |
146 if member is None: |
151 def my_local_func(*args, **kwargs): |
147 def my_local_func(*args, **kwargs): |
152 return RemotePLCObjectProxy.__getattr__(attrName)(*args, **kwargs) |
148 return RemotePLCObjectProxy.__getattr__(attrName)(*args, **kwargs) |