Renaming servicetype into scheme.
authorEdouard Tisserant
Mon, 19 Nov 2018 10:39:50 +0100
changeset 2338 2c3222433244
parent 2337 8689ce77076f
child 2339 48b4eba13064
Renaming servicetype into scheme.
connectors/PYRO/__init__.py
connectors/WAMP/__init__.py
connectors/__init__.py
--- a/connectors/PYRO/__init__.py	Fri Nov 16 14:04:51 2018 +0100
+++ b/connectors/PYRO/__init__.py	Mon Nov 19 10:39:50 2018 +0100
@@ -51,8 +51,8 @@
     """
     confnodesroot.logger.write(_("PYRO connecting to URI : %s\n") % uri)
 
-    servicetype, location = uri.split("://")
-    if servicetype == "PYROS":
+    scheme, location = uri.split("://")
+    if scheme == "PYROS":
         import connectors.PYRO.PSK_Adapter
         schemename = "PYROLOCPSK"
         url, ID = location.split('#') #TODO fix exception when # not found
@@ -124,7 +124,7 @@
         confnodesroot.logger.write_error(_("Cannot get PLC ID - connection failed.\n"))
         return None
 
-    if servicetype != "PYROS":
+    if scheme != "PYROS":
         ID,PSK = IDPSK
         secdir = os.path.join(str(confnodesroot.ProjectPath), 'psk')
         if not os.path.exists(secdir):
--- a/connectors/WAMP/__init__.py	Fri Nov 16 14:04:51 2018 +0100
+++ b/connectors/WAMP/__init__.py	Mon Nov 19 10:39:50 2018 +0100
@@ -69,10 +69,10 @@
     WAMP://127.0.0.1:12345/path#realm#ID
     WAMPS://127.0.0.1:12345/path#realm#ID
     """
-    servicetype, location = uri.split("://")
+    scheme, location = uri.split("://")
     urlpath, realm, ID = location.split('#')
     urlprefix = {"WAMP":  "ws",
-                 "WAMPS": "wss"}[servicetype]
+                 "WAMPS": "wss"}[scheme]
     url = urlprefix+"://"+urlpath
 
     def RegisterWampClient():
--- a/connectors/__init__.py	Fri Nov 16 14:04:51 2018 +0100
+++ b/connectors/__init__.py	Mon Nov 19 10:39:50 2018 +0100
@@ -64,25 +64,25 @@
     Return a connector corresponding to the URI
     or None if cannot connect to URI
     """
-    servicetype = uri.split("://")[0].upper()
-    if servicetype == "LOCAL":
+    scheme = uri.split("://")[0].upper()
+    if scheme == "LOCAL":
         # Local is special case
         # pyro connection to local runtime
         # started on demand, listening on random port
-        servicetype = "PYRO"
+        scheme = "PYRO"
         runtime_port = confnodesroot.AppFrame.StartLocalRuntime(
             taskbaricon=True)
         uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
-    elif servicetype in connectors:
+    elif scheme in connectors:
         pass
-    elif servicetype[-1] == 'S' and servicetype[:-1] in connectors:
-        servicetype = servicetype[:-1]
+    elif scheme[-1] == 'S' and scheme[:-1] in connectors:
+        scheme = scheme[:-1]
     else:
         return None
 
     # import module according to uri type
-    connectorclass = connectors[servicetype]()
     return connectorclass(uri, confnodesroot)
+    connectorclass = connectors[scheme]()
 
 
 def EditorClassFromScheme(scheme):