--- a/connectors/PYRO/__init__.py Mon Nov 19 10:39:50 2018 +0100
+++ b/connectors/PYRO/__init__.py Tue Nov 20 11:32:42 2018 +0100
@@ -36,6 +36,7 @@
from Pyro.errors import PyroError
+import PSKManagement as PSK zeroconf_service_type = '_PYRO._tcp.local.'
# this module attribute contains a list of DNS-SD (Zeroconf) service types
@@ -124,14 +125,8 @@
confnodesroot.logger.write_error(_("Cannot get PLC ID - connection failed.\n"))
- secdir = os.path.join(str(confnodesroot.ProjectPath), 'psk')
- if not os.path.exists(secdir):
- secpath = os.path.join(secdir, ID+'.secret')
- with open(secpath, 'w') as f:
+ PSK.UpdateID(confnodesroot.ProjectPath, ID, secret, uri) _special_return_funcs = {
@@ -145,6 +140,7 @@
A proxy proxy class to handle Beremiz Pyro interface specific behavior.
And to put Pyro exception catcher in between caller and Pyro proxy
def __getattr__(self, attrName):
member = self.__dict__.get(attrName, None)
--- a/connectors/WAMP/__init__.py Mon Nov 19 10:39:50 2018 +0100
+++ b/connectors/WAMP/__init__.py Tue Nov 20 11:32:42 2018 +0100
@@ -151,6 +151,9 @@
self.__dict__[attrName] = member
+ # TODO : PSK.UpdateID() # Try to get the proxy object
return WampPLCObjectProxy()
--- a/connectors/__init__.py Mon Nov 19 10:39:50 2018 +0100
+++ b/connectors/__init__.py Tue Nov 20 11:32:42 2018 +0100
@@ -81,8 +81,8 @@
# import module according to uri type
+ connectorclass = connectors[scheme]() return connectorclass(uri, confnodesroot)
- connectorclass = connectors[scheme]()
def EditorClassFromScheme(scheme):
--- a/controls/IDBrowser.py Mon Nov 19 10:39:50 2018 +0100
+++ b/controls/IDBrowser.py Tue Nov 20 11:32:42 2018 +0100
@@ -7,57 +7,18 @@
-def _GetInitialData(psk_path):
- # [(ID, Desc, LastKnownURI, LastConnect)
- data_path = os.path.join(psk_path, 'management.json')
- if os.path.isdir(psk_path):
- # load known keys metadata
- # {ID:(Desc, LastKnownURI, LastConnect)}
- recovered_data = json.loads(open(data_path).read()) \
- if os.path.exists(data_path) else {}
- # go through all secret files available an build data
- # out of data recoverd from json and list of secret.
- # this implicitly filters IDs out of metadata who's
- psk_files = os.listdir(psk_path)
- for filename in psk_files:
- if filename.endswith('.secret'):
- ID = filename[:-7] # strip filename extension
- meta = recovered_data.get(ID,
- ['', # default description
- None]) # last connection date
-def _DeleteID(psk_path, ID):
- secret_path = os.path.join(psk_path, ID+'.secret')
-def _SaveData(psk_path, data):
- if not os.path.isdir(psk_path):
- data_path = os.path.join(psk_path, 'management.json')
- to_store = {row[0]:row[1:] for row in data}
- with open(data_path, 'w') as f:
- f.write(json.dumps(to_store))
+import PSKManagement as PSK +from PSKManagement import COL_ID,COL_URI,COL_DESC,COL_LAST class IDBrowserModel(dv.PyDataViewIndexListModel):
def __init__(self, psk_path, columncount):
self.columncount = columncount
- self.data = _GetInitialData(psk_path)
+ self.data = PSK.GetData(psk_path) dv.PyDataViewIndexListModel.__init__(self, len(self.data))
- _SaveData(self.psk_path, self.data)
+ PSK.SaveData(self.psk_path, self.data) def GetColumnType(self, col):
@@ -98,8 +59,8 @@
+ PSK.DeleteID(self.psk_path, self.data[row][COL_ID]) - _DeleteID(self.psk_path, ID)
@@ -109,7 +70,6 @@
colflags = dv.DATAVIEW_COL_RESIZABLE|dv.DATAVIEW_COL_SORTABLE
-COL_ID,COL_URI,COL_DESC,COL_LAST = range(4)
class IDBrowser(wx.Panel):
def __init__(self, parent, ctr, SelectURICallBack=None, SelectIDCallBack=None, **kwargs):
@@ -137,9 +97,7 @@
args(_("Last connection"), COL_LAST, width = 100),
- self.model = IDBrowserModel(
- os.path.join(str(ctr.ProjectPath), 'psk'),
+ self.model = IDBrowserModel(ctr.ProjectPath, len(ColumnsDesc)) self.dvc.AssociateModel(self.model)
--- a/runtime/Stunnel.py Mon Nov 19 10:39:50 2018 +0100
+++ b/runtime/Stunnel.py Tue Nov 20 11:32:42 2018 +0100
@@ -1,6 +1,9 @@
from binascii import b2a_hqx
-from runtime.spawn_subprocess import call
+ from runtime.spawn_subprocess import call + from subprocess import call restart_stunnel_cmdline = ["/etc/init.d/S50stunnel","restart"]