--- a/connectors/PYRO/__init__.py Thu Oct 20 19:30:23 2022 +0800
+++ b/connectors/PYRO/__init__.py Sun Oct 30 13:20:58 2022 +0800
@@ -23,35 +23,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from Pyro.errors import PyroError
-import PSKManagement as PSK
-from connectors.PYRO.PSK_Adapter import setupPSKAdapter
from runtime import PlcStatus
-def switch_pyro_adapter(use_ssl):
- Reloads Pyro module with new settings.
- This is workaround for Pyro, because it doesn't work with SSL wrapper.
- # Pyro.config.PYRO_BROKEN_MSGWAITALL = use_ssl
- importlib.reload(Pyro.protocol)
+Pyro5.config.SERPENT_BYTES_REPR = True def PYRO_connector_factory(uri, confnodesroot):
@@ -60,34 +48,21 @@
confnodesroot.logger.write(_("PYRO connecting to URI : %s\n") % uri)
scheme, location = uri.split("://")
- use_ssl = scheme == "PYROS"
- switch_pyro_adapter(use_ssl)
- schemename = "PYROLOCPSK"
- url, ID = location.split('#') # TODO fix exception when # not found
- # load PSK from project
- secpath = os.path.join(str(confnodesroot.ProjectPath), 'psk', ID+'.secret')
- if not os.path.exists(secpath):
- confnodesroot.logger.write_error(
- 'Error: Pre-Shared-Key Secret in %s is missing!\n' % secpath)
- secret = open(secpath).read().partition(':')[2].rstrip('\n\r')
- Pyro.config.PYROPSK = (secret, ID)
- # strip ID from URL, so that pyro can understand it.
# Try to get the proxy object
- RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject")
+ RemotePLCObjectProxy = Pyro5.client.Proxy(f"{schemename}:PLCObject@{location}") confnodesroot.logger.write_error(
_("Connection to {loc} failed with exception {ex}\n").format(
loc=location, ex=str(e)))
- RemotePLCObjectProxy.adapter.setTimeout(60)
+ RemotePLCObjectProxy._pyroTimeout = 60 def PyroCatcher(func, default=None):
@@ -97,14 +72,14 @@
def catcher_func(*args, **kwargs):
return func(*args, **kwargs)
- except Pyro.errors.ConnectionClosedError as e:
+ except Pyro5.errors.ConnectionClosedError as e: confnodesroot._SetConnector(None)
confnodesroot.logger.write_error(_("Connection lost!\n"))
- except Pyro.errors.ProtocolError as e:
+ except Pyro5.errors.ProtocolError as e: confnodesroot.logger.write_error(_("Pyro exception: %s\n") % e)
# confnodesroot.logger.write_error(traceback.format_exc())
- errmess = ''.join(Pyro.util.getPyroTraceback(e))
+ errmess = ''.join(Pyro5.errors.get_pyro_traceback(e)) confnodesroot.logger.write_error(errmess + "\n")
confnodesroot._SetConnector(None)
--- a/connectors/PYRO_dialog.py Thu Oct 20 19:30:23 2022 +0800
+++ b/connectors/PYRO_dialog.py Sun Oct 30 13:20:58 2022 +0800
@@ -14,9 +14,9 @@
# (scheme, model, secure)
-models = [("LOCAL", [], False), ("PYRO", model, False), ("PYROS", model, True)]
+models = [("LOCAL", [], False), ("PYRO", model, False)] -Schemes = list(zip(*models)[0])
+Schemes = list(zip(*models))[0] _PerSchemeConf = {sch: (mod, sec) for sch, mod, sec in models}
--- a/connectors/__init__.py Thu Oct 20 19:30:23 2022 +0800
+++ b/connectors/__init__.py Sun Oct 30 13:20:58 2022 +0800
@@ -31,7 +31,7 @@
from os import listdir, path
from connectors.ConnectorBase import ConnectorBase
-connectors_packages = ["PYRO", "WAMP"]
+connectors_packages = ["PYRO"] def _GetLocalConnectorClassFactory(name):
@@ -81,7 +81,7 @@
# started on demand, listening on random port
runtime_port = confnodesroot.StartLocalRuntime()
- uri = "PYROLOC://"+LocalHost+":" + str(runtime_port)
+ uri = f"PYRO://{LocalHost}:{runtime_port}" # commented code to enable for MDNS:// support
# elif _scheme == "MDNS":
--- a/runtime/PLCObject.py Thu Oct 20 19:30:23 2022 +0800
+++ b/runtime/PLCObject.py Sun Oct 30 13:20:58 2022 +0800
@@ -56,7 +56,7 @@
@@ -80,8 +80,7 @@
if os.path.exists(self.tmpdir):
shutil.rmtree(self.tmpdir)
- # FIXME : is argv of any use nowadays ?
- self.argv = [WorkingDir] + argv # force argv[0] to be "path" to exec...
self.statuschange = statuschange
self.evaluator = evaluator
self.pyruntimevars = pyruntimevars