Ejemplo n.º 1
0
def main():
    exit_code = startup_options()
    if exit_code is not None:
        return exit_code
    logger = logging.getLogger("fastflix-core")
    logger.addHandler(reusables.get_stream_handler(level=logging.DEBUG))
    logger.setLevel(logging.DEBUG)
    coloredlogs.install(level="DEBUG", logger=logger)
    logger.info(f"Starting FastFlix {__version__}")

    worker_queue = Queue()
    status_queue = Queue()
    log_queue = Queue()

    gui_proc = Process(
        target=separate_app_process,
        args=(
            worker_queue,
            status_queue,
            log_queue,
        ),
    )
    gui_proc.start()
    exit_status = 1
    try:
        queue_worker(gui_proc, worker_queue, status_queue, log_queue)
        exit_status = 0
    finally:
        gui_proc.kill()
        return exit_status
Ejemplo n.º 2
0
 def test_remove_stream_handlers(self):
     logger = reusables.get_logger("sample_stream_logger", file_path=my_stream_path)
     logger.addHandler(logging.NullHandler())
     for _ in range(10):
         logger.addHandler(reusables.get_stream_handler())
     reusables.remove_stream_handlers("sample_stream_logger")
     assert len(logger.handlers) == 2, logger.handlers
     assert isinstance(logger.handlers[0], logging.FileHandler)
     reusables.remove_all_handlers(logger)
Ejemplo n.º 3
0
def init_logging(app: FastFlixApp):
    stream_handler = reusables.get_stream_handler(level=logging.DEBUG)
    file_handler = reusables.get_file_handler(
        app.fastflix.log_path / f"flix_gui_{file_date()}.log",
        level=logging.DEBUG,
        encoding="utf-8",
    )
    logger.setLevel(logging.DEBUG)
    logger.addHandler(stream_handler)
    logger.addHandler(file_handler)
    coloredlogs.install(level="DEBUG", logger=logger)
Ejemplo n.º 4
0
def main():
    exit_code = startup_options()
    if exit_code is not None:
        return exit_code
    logger = logging.getLogger("fastflix-core")
    logger.addHandler(reusables.get_stream_handler(level=logging.DEBUG))
    logger.setLevel(logging.DEBUG)
    coloredlogs.install(level="DEBUG", logger=logger)
    logger.info(f"Starting FastFlix {__version__}")

    worker_queue = Queue()
    status_queue = Queue()
    log_queue = Queue()

    queue_lock = Lock()
    with Manager() as manager:
        queue_list = manager.list()
        exit_status = 1

        try:
            gui_proc = Process(
                target=separate_app_process,
                args=(worker_queue, status_queue, log_queue, queue_list,
                      queue_lock),
            )
            gui_proc.start()
        except Exception:
            logger.exception(
                "Could not create GUI Process, please report this error!")
            return exit_status

        try:
            queue_worker(gui_proc, worker_queue, status_queue, log_queue,
                         queue_list, queue_lock)
            exit_status = 0
        except Exception:
            logger.exception("Exception occurred while running FastFlix core")
        finally:
            gui_proc.kill()
            return exit_status