merged
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 11 Apr 2019 08:40:17 +0200
changeset 2590 f8c66edffbd4
parent 2588 25f19b76c7b6 (diff)
parent 2589 d94d4f396bbf (current diff)
child 2591 5f685bcd3ad6
merged
--- a/connectors/PYRO/PSK_Adapter.py	Wed Apr 10 14:11:52 2019 +0200
+++ b/connectors/PYRO/PSK_Adapter.py	Thu Apr 11 08:40:17 2019 +0200
@@ -34,13 +34,17 @@
 import socket
 import re
 import ssl
-import sslpsk
 import Pyro
 from Pyro.core import PyroURI
 from Pyro.protocol import _connect_socket, TCPConnection, PYROAdapter
 from Pyro.errors import ConnectionDeniedError, ProtocolError
 from Pyro.util import Log
 
+try:
+    import sslpsk
+except ImportError as e:
+    print(str(e))
+    sslpsk = None
 
 class PYROPSKAdapter(PYROAdapter):
     """
@@ -126,5 +130,8 @@
     This function should be called after
     reimport of Pyro module to enable PYROS:// again.
     """
-    Pyro.protocol.getProtocolAdapter = getProtocolAdapter
-    Pyro.core.processStringURI = processStringURI
+    if sslpsk is not None:
+        Pyro.protocol.getProtocolAdapter = getProtocolAdapter
+        Pyro.core.processStringURI = processStringURI
+    else:
+        raise Exception("sslpsk python module unavailable")
--- a/connectors/PYRO/__init__.py	Wed Apr 10 14:11:52 2019 +0200
+++ b/connectors/PYRO/__init__.py	Thu Apr 11 08:40:17 2019 +0200
@@ -37,7 +37,7 @@
 from Pyro.errors import PyroError
 
 import PSKManagement as PSK
-import connectors.PYRO.PSK_Adapter
+from connectors.PYRO.PSK_Adapter import setupPSKAdapter
 from runtime import PlcStatus
 
 
@@ -49,7 +49,7 @@
     # Pyro.config.PYRO_BROKEN_MSGWAITALL = use_ssl
     reload(Pyro.protocol)
     if use_ssl:
-        connectors.PYRO.PSK_Adapter.setupPSKAdapter()
+        setupPSKAdapter()
 
 
 def PYRO_connector_factory(uri, confnodesroot):