runtime/Stunnel.py
changeset 2542 a3ec35ee94e7
parent 2492 7dd551ac2fa0
child 3750 f62625418bff
--- a/runtime/Stunnel.py	Wed Mar 13 14:14:31 2019 +0300
+++ b/runtime/Stunnel.py	Wed Mar 13 14:27:24 2019 +0300
@@ -1,4 +1,5 @@
 from __future__ import absolute_import
+from __future__ import print_function
 import os
 from binascii import b2a_hqx
 try:
@@ -11,6 +12,17 @@
 _PSKpath = None
 
 
+def restartStunnel():
+    """
+    Restart stunnel service using SysV init stript
+    to apply new generated credentials
+    """
+    try:
+        call(restart_stunnel_cmdline)
+    except OSError:
+        print(_("Couldn't restart stunnel service"))
+
+
 def PSKgen(ID, PSKpath):
 
     # b2a_hqx output len is 4/3 input len
@@ -20,7 +32,7 @@
     PSKstring = ID+":"+secretstring
     with open(PSKpath, 'w') as f:
         f.write(PSKstring)
-    call(restart_stunnel_cmdline)
+    restartStunnel()
 
 
 def ensurePSK(ID, PSKpath):