connectors/__init__.py
changeset 2478 733d77bf0aa7
parent 2469 e8760be772d5
child 2492 7dd551ac2fa0
equal deleted inserted replaced
2477:4866c01e7428 2478:733d77bf0aa7
    65     """
    65     """
    66     Return a connector corresponding to the URI
    66     Return a connector corresponding to the URI
    67     or None if cannot connect to URI
    67     or None if cannot connect to URI
    68     """
    68     """
    69     _scheme = uri.split("://")[0].upper()
    69     _scheme = uri.split("://")[0].upper()
       
    70 
       
    71     # commented code to enable for MDNS:// support
       
    72     # _scheme, location = uri.split("://")
       
    73     # _scheme = _scheme.upper()
       
    74 
    70     if _scheme == "LOCAL":
    75     if _scheme == "LOCAL":
    71         # Local is special case
    76         # Local is special case
    72         # pyro connection to local runtime
    77         # pyro connection to local runtime
    73         # started on demand, listening on random port
    78         # started on demand, listening on random port
    74         scheme = "PYRO"
    79         scheme = "PYRO"
    75         runtime_port = confnodesroot.AppFrame.StartLocalRuntime(
    80         runtime_port = confnodesroot.AppFrame.StartLocalRuntime(
    76             taskbaricon=True)
    81             taskbaricon=True)
    77         uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
    82         uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
       
    83 
       
    84     # commented code to enable for MDNS:// support
       
    85     # elif _scheme == "MDNS":
       
    86     #     try:
       
    87     #         from zeroconf import Zeroconf
       
    88     #         r = Zeroconf()
       
    89     #         i = r.get_service_info(zeroconf_service_type, location)
       
    90     #         if i is None:
       
    91     #             raise Exception("'%s' not found" % location)
       
    92     #         ip = str(socket.inet_ntoa(i.address))
       
    93     #         port = str(i.port)
       
    94     #         newlocation = ip + ':' + port
       
    95     #         confnodesroot.logger.write(_("'{a1}' is located at {a2}\n").format(a1=location, a2=newlocation))
       
    96     #         location = newlocation
       
    97     #         # not a bug, but a workaround against obvious downgrade attack
       
    98     #         scheme = "PYROS"
       
    99     #         r.close()
       
   100     #     except Exception:
       
   101     #         confnodesroot.logger.write_error(_("MDNS resolution failure for '%s'\n") % location)
       
   102     #         confnodesroot.logger.write_error(traceback.format_exc())
       
   103     #         return None
       
   104 
    78     elif _scheme in connectors:
   105     elif _scheme in connectors:
    79         scheme = _scheme
   106         scheme = _scheme
    80     elif _scheme[-1] == 'S' and _scheme[:-1] in connectors:
   107     elif _scheme[-1] == 'S' and _scheme[:-1] in connectors:
    81         scheme = _scheme[:-1]
   108         scheme = _scheme[:-1]
    82     else:
   109     else: