connectors/PYRO/__init__.py
changeset 2338 2c3222433244
parent 2334 d1470c052662
child 2339 48b4eba13064
equal deleted inserted replaced
2337:8689ce77076f 2338:2c3222433244
    49     """
    49     """
    50     This returns the connector to Pyro style PLCobject
    50     This returns the connector to Pyro style PLCobject
    51     """
    51     """
    52     confnodesroot.logger.write(_("PYRO connecting to URI : %s\n") % uri)
    52     confnodesroot.logger.write(_("PYRO connecting to URI : %s\n") % uri)
    53 
    53 
    54     servicetype, location = uri.split("://")
    54     scheme, location = uri.split("://")
    55     if servicetype == "PYROS":
    55     if scheme == "PYROS":
    56         import connectors.PYRO.PSK_Adapter
    56         import connectors.PYRO.PSK_Adapter
    57         schemename = "PYROLOCPSK"
    57         schemename = "PYROLOCPSK"
    58         url, ID = location.split('#') #TODO fix exception when # not found
    58         url, ID = location.split('#') #TODO fix exception when # not found
    59         # load PSK from project
    59         # load PSK from project
    60         secpath = os.path.join(str(confnodesroot.ProjectPath), 'psk', ID+'.secret')
    60         secpath = os.path.join(str(confnodesroot.ProjectPath), 'psk', ID+'.secret')
   122     IDPSK = PyroCatcher(RemotePLCObjectProxy.GetPLCID)()
   122     IDPSK = PyroCatcher(RemotePLCObjectProxy.GetPLCID)()
   123     if IDPSK is None:
   123     if IDPSK is None:
   124         confnodesroot.logger.write_error(_("Cannot get PLC ID - connection failed.\n"))
   124         confnodesroot.logger.write_error(_("Cannot get PLC ID - connection failed.\n"))
   125         return None
   125         return None
   126 
   126 
   127     if servicetype != "PYROS":
   127     if scheme != "PYROS":
   128         ID,PSK = IDPSK
   128         ID,PSK = IDPSK
   129         secdir = os.path.join(str(confnodesroot.ProjectPath), 'psk')
   129         secdir = os.path.join(str(confnodesroot.ProjectPath), 'psk')
   130         if not os.path.exists(secdir):
   130         if not os.path.exists(secdir):
   131             os.mkdir(secdir)
   131             os.mkdir(secdir)
   132         secpath = os.path.join(secdir, ID+'.secret')
   132         secpath = os.path.join(secdir, ID+'.secret')