def __init__(self, standalone=False, interval=1, input_stream=sys.stdin): self.modules = util.ModuleList(self, ClassFinder(Module)) self.standalone = standalone if standalone: self.io = io.StandaloneIO(interval) self.command_endpoint = CommandEndpoint( self.modules, lambda: io.JSONIO(io=io.IOHandler(sys.stdin, open(os.devnull, "w")), skiplines=1)) else: self.io = io.IOHandler(input_stream)
def __init__(self, standalone=True, click_events=True, interval=1, input_stream=None, logfile=None, internet_check=None, keep_alive=False, logformat=DEFAULT_LOG_FORMAT, default_hints={"markup": "none"}): self.standalone = standalone self.default_hints = default_hints self.click_events = standalone and click_events input_stream = input_stream or sys.stdin logger = logging.getLogger("i3pystatus") if logfile: for handler in logger.handlers: logger.removeHandler(handler) logfile = os.path.expandvars(logfile) handler = logging.FileHandler(logfile, delay=True) logger.addHandler(handler) logger.setLevel(logging.CRITICAL) if logformat: for index in range(len(logger.handlers)): logger.handlers[index].setFormatter( logging.Formatter(logformat)) if internet_check: util.internet.address = internet_check self.modules = util.ModuleList(self, ClassFinder(Module)) if self.standalone: self.io = io.StandaloneIO(self.click_events, self.modules, keep_alive, interval) if self.click_events: self.command_endpoint = CommandEndpoint( self.modules, lambda: io.JSONIO(io=io.IOHandler( sys.stdin, open(os.devnull, "w")), skiplines=1), self.io) else: self.io = io.IOHandler(input_stream)
def setUp(self): self.status_handler = MagicMock() self.ml = util.ModuleList(self.status_handler, ClassFinder(self.ModuleBase))