connectors/PYRO/PSK_Adapter.py
changeset 2588 25f19b76c7b6
parent 2544 640d639d9bd8
child 2597 7e20fe7facd6
equal deleted inserted replaced
2587:c67488bd8134 2588:25f19b76c7b6
    32 from __future__ import print_function
    32 from __future__ import print_function
    33 
    33 
    34 import socket
    34 import socket
    35 import re
    35 import re
    36 import ssl
    36 import ssl
    37 import sslpsk
       
    38 import Pyro
    37 import Pyro
    39 from Pyro.core import PyroURI
    38 from Pyro.core import PyroURI
    40 from Pyro.protocol import _connect_socket, TCPConnection, PYROAdapter
    39 from Pyro.protocol import _connect_socket, TCPConnection, PYROAdapter
    41 from Pyro.errors import ConnectionDeniedError, ProtocolError
    40 from Pyro.errors import ConnectionDeniedError, ProtocolError
    42 from Pyro.util import Log
    41 from Pyro.util import Log
    43 
    42 
       
    43 try:
       
    44     import sslpsk
       
    45 except ImportError as e:
       
    46     print(str(e))
       
    47     sslpsk = None
    44 
    48 
    45 class PYROPSKAdapter(PYROAdapter):
    49 class PYROPSKAdapter(PYROAdapter):
    46     """
    50     """
    47     This is essentialy the same as in Pyro/protocol.py
    51     This is essentialy the same as in Pyro/protocol.py
    48     only raw_sock wrapping into sock through sslpsk.wrap_socket was added
    52     only raw_sock wrapping into sock through sslpsk.wrap_socket was added
   124     Pyro adapters and handle new supported protocols
   128     Pyro adapters and handle new supported protocols
   125 
   129 
   126     This function should be called after
   130     This function should be called after
   127     reimport of Pyro module to enable PYROS:// again.
   131     reimport of Pyro module to enable PYROS:// again.
   128     """
   132     """
   129     Pyro.protocol.getProtocolAdapter = getProtocolAdapter
   133     if sslpsk is not None:
   130     Pyro.core.processStringURI = processStringURI
   134         Pyro.protocol.getProtocolAdapter = getProtocolAdapter
       
   135         Pyro.core.processStringURI = processStringURI
       
   136     else:
       
   137         raise Exception("sslpsk python module unavailable")