예제 #1
0
    parser = argparse.ArgumentParser()
    parser.add_argument("--verbose", dest="is_verbose", action="store_true")
    # :TODO: разобраться, как можно попроще записывать
    # булевские аргументы по умолчанию=True
    parser.add_argument("--is_not_dvr_read", dest="is_not_dvr_read", action="store_true")

    args = parser.parse_args()

    is_dvr_read = not args.is_not_dvr_read

    # логирование
    import os

    log_fpath = os.path.join(os.path.dirname(__file__), "../log/d_t_s.log")
    logging_level = logging.DEBUG if args.is_verbose else logging.INFO
    api.setup_logger(logger, log_fpath, logging_level)

    if is_dvr_read:
        handle_stream = handle_dvr_stream
    else:

        def handle_stream(self, stream, address):
            stream.read_until_close(on_read, streaming_callback=on_read)

    from test_sendfile import start_tcp_server, run_loop

    port = 6451
    start_tcp_server(handle_stream, port)
    run_loop()
예제 #2
0
def setup_logger(logger, fname, logging_level):
    api.setup_logger(logger, log_name2path(fname), logging_level)
예제 #3
0
    # :TODO: разобраться, как можно попроще записывать
    # булевские аргументы по умолчанию=True
    parser.add_argument(
        '--is_not_dvr_read',
        dest='is_not_dvr_read',
        action="store_true",
    )

    args = parser.parse_args()

    is_dvr_read = not args.is_not_dvr_read

    # логирование
    import os
    log_fpath = os.path.join(os.path.dirname(__file__), '../log/d_t_s.log')
    logging_level = logging.DEBUG if args.is_verbose else logging.INFO
    api.setup_logger(logger, log_fpath, logging_level)

    if is_dvr_read:
        handle_stream = handle_dvr_stream
    else:

        def handle_stream(self, stream, address):
            stream.read_until_close(on_read, streaming_callback=on_read)

    from test_sendfile import start_tcp_server, run_loop

    port = 6451
    start_tcp_server(handle_stream, port)
    run_loop()
예제 #4
0
def setup_logger(logger, fname, logging_level):
    api.setup_logger(logger, log_name2path(fname), logging_level)