Пример #1
0
    def __init__(
        self, filename=None, sep=default_sep, port=default_port, rpc_export=True, start_server=True, *args, **kwargs
    ):
        self.filename = filename
        self.sep = sep
        self.port = port
        self.serverStarted = False

        self.initTime = time.time()
        self.logger = logging.getLogger(self.__class__.__name__)
        if self.filename is None:
            self.filename = "logs/events_{}.log".format(
                time.strftime(self.timestamp_format, time.localtime(self.initTime))
            )
        try:
            self.out = open(self.filename, "w")
            if rpc_export:
                rpc.export(self)  # NOTE prepends class name to all RPC-enabled method names
                if start_server:
                    rpc.start_server_thread(port=self.port, *args, **kwargs)
                    self.serverStarted = True
        except Exception as e:
            self.logger.error("Error opening log file or starting RPC server: %s", str(e))
        self.logger.info("Logger successfully initialized; filename: %s", self.filename)
Пример #2
0
 def __init__(self, port=default_port, start_server=True, *args, **kwargs):
     OutputDevice.__init__(self)
     self.isFresh = True  # used to prevent clients from getting a None as the first image
     rpc.export(self)  # NOTE prepends class name to all RPC-enabled method names
     if start_server:
         rpc.start_server_thread(port=port, *args, **kwargs)