Small cosmetic change to enhance readability and avoid confusion.
authorEdouard Tisserant
Tue, 23 Oct 2018 13:36:07 +0200
changeset 2321 0a3103cd825d
parent 2320 dd959601e67a
child 2322 7ce4e5cf6339
Small cosmetic change to enhance readability and avoid confusion.
Beremiz_service.py
runtime/Stunnel.py
--- a/Beremiz_service.py	Tue Oct 23 13:34:15 2018 +0200
+++ b/Beremiz_service.py	Tue Oct 23 13:36:07 2018 +0200
@@ -334,9 +334,9 @@
                     self.pyroserver.Restart()
 
             def OnTaskBarChangeName(self, evt):
-                servicename = self.pyroserver.servicename
-                servicename = '' if servicename is None else servicename
-                dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=servicename)
+                _servicename = self.pyroserver.servicename
+                _servicename = '' if _servicename is None else _servicename
+                dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=_servicename)
                 dlg.SetTests([(lambda name: len(name) is not 0, _("Name must not be null!"))])
                 if dlg.ShowModal() == wx.ID_OK:
                     self.pyroserver.servicename = dlg.GetValue()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runtime/Stunnel.py	Tue Oct 23 13:36:07 2018 +0200
@@ -0,0 +1,18 @@
+import os
+from binascii import hexlify
+
+restart_stunnel_cmdline = ["/etc/init.d/S50stunnel","restart"]
+
+def pskgen(ID, pskpath):
+    secretstring = hexlify(os.urandom(256))
+    pskstring = ID+":"+secretstring
+    with open(pskpath, 'w') as f:
+        f.write(pskstring)
+    call(restart_stunnel_cmdline)
+
+def ensurepsk(ID, pskpath):
+    # check if already there
+    if not os.path.exists(pskpath):
+        # create if needed
+        pskgen(IS, pskpath)
+