Exemplo n.º 1
0
    def __init__(self, host="127.0.0.1", port=None, token=None):
        """
        Constructor for Transport
        :param host: Hostname as a String
        :param port: optional port as a positive Integer
        :param token: optional token
        """
        self.logger = get_logger()
        self.__token = None
        self.__host = None
        if token:
            self.set_token(token)

        self.set_host(host, port)
        self.logger.info("OpenTMI host: %s", self.host)
Exemplo n.º 2
0
 def __init__(self,
              host='127.0.0.1',
              port=None,
              transport=None,
              logger=None):
     """
     Constructor for OpenTMI client
     :param host: opentmi host address (default="localhost")
     :param port: opentmi server port (default=3000)
     :param transport: optional Transport layer. Mostly for testing purpose
     :param logger: optional Logging instance.
     """
     self.__logger = logger or get_logger()
     self.__transport = Transport(host,
                                  port) if not transport else transport
     # backward compatibility
     self.__result_converter = None
     self.__tc_converter = None
     self.try_login()
Exemplo n.º 3
0
 def test_default_logger(self):
     logger = get_logger()
     self.assertIsInstance(logger, Logger)
     self.assertEqual(len(logger.handlers), 1)
Exemplo n.º 4
0
 def test_set_logger(self):
     client = OpenTmiClient()
     client.set_logger(get_logger(level=DEBUG))
Exemplo n.º 5
0
 def test_null_logger(self):
     logger = get_logger(name="new", level=None)
     self.assertIsInstance(logger, Logger)
     self.assertEqual(len(logger.handlers), 1)