예제 #1
0
파일: utils.py 프로젝트: td00/pretalx
def log_initial(DEBUG, config_files, db_name, db_backend, LOG_DIR):
    from pretalx.common.console import start_box, end_box, print_line
    mode = 'development' if DEBUG else 'production'
    lines = [
        (f'This is pretalx calling, running in {mode} mode.', True),
        ('', False),
        (f'Settings:', True),
        (f'Read from: {config_files}', False),
        (f'Database: {db_name} ({db_backend})', False),
        (f'Logging:  {LOG_DIR}', False),
        ('', False),
    ]
    image = '''
┏━━━━━━━━━━┓
┃  ┌─·──╮  ┃
┃  │  O │  ┃
┃  │ ┌──╯  ┃
┃  └─┘     ┃
┗━━━┯━┯━━━━┛
    ╰─╯
    '''.strip().split('\n')

    lines = [(f'{image[n]}  {lines[n][0]}', lines[n][1])
             for n in range(len(lines))]

    size = max(len(line[0]) for line in lines) + 4
    start_box(size)
    for line in lines:
        print_line(line[0], box=True, bold=line[1], size=size)
    end_box(size)
예제 #2
0
def log_initial():
    from pretalx.common.console import start_box, end_box, print_line
    mode = 'development' if DEBUG else 'production'
    lines = [
        (f'This is pretalx calling, running in {mode} mode.', True),
        ('', False),
        (f'Settings:', True),
        (f'Read from: {config_files}', False),
        (f'Database: {db_name} ({db_backend})', False),
        (f'Logging:  {LOG_DIR}', False),
        ('', False),
    ]

    size = max(len(line[0]) for line in lines) + 4
    start_box(size)
    for line in lines:
        print_line(line[0], box=True, bold=line[1], size=size)
    end_box(size)
예제 #3
0
def log_initial(*, debug, config_files, db_name, db_backend, LOG_DIR, plugins):
    from pretalx import __version__
    from pretalx.common.console import end_box, print_line, start_box

    with suppress(Exception):  # geteuid is not available on all OS
        if os.geteuid() == 0:
            print_line("You are running pretalx as root, why?", bold=True)

    lines = [
        (f"pretalx v{__version__}", True),
        (f'Settings:  {", ".join(config_files)}', False),
        (f"Database:  {db_name} ({db_backend})", False),
        (f"Logging:   {LOG_DIR}", False),
        (f"Root dir:  {Path(__file__).parent.parent.parent}", False),
        (f"Python:    {executable}", False),
    ]
    if plugins:
        lines += [(f'Plugins:   {",".join(plugins)}', False)]
    if debug:
        lines += [("DEVELOPMENT MODE, DO NOT USE IN PRODUCTION!", True)]
    image = """
┏━━━━━━━━━━┓
┃  ┌─·──╮  ┃
┃  │  O │  ┃
┃  │ ┌──╯  ┃
┃  └─┘     ┃
┗━━━┯━┯━━━━┛
    ╰─╯
    """.strip().split(
        "\n"
    )
    img_width = len(image[0])
    image[-1] += " " * (img_width - len(image[-1]))
    image += [" " * img_width for _ in repeat(None, (len(lines) - len(image)))]

    lines = [(f"{image[n]}  {line[0]}", line[1]) for n, line in enumerate(lines)]

    size = max(len(line[0]) for line in lines) + 4
    start_box(size)
    for line in lines:
        print_line(line[0], box=True, bold=line[1], size=size)
    end_box(size)
예제 #4
0
파일: utils.py 프로젝트: Hydro2shine/sprout
def log_initial(*, debug, config_files, db_name, db_backend, LOG_DIR, plugins):
    from pretalx.common.console import start_box, end_box, print_line
    from pretalx import __version__

    if os.geteuid() == 0:
        print_line('You are running pretalx as root, why?', bold=True)

    lines = [
        (f'pretalx v{__version__}', True),
        (f'Settings:  {", ".join(config_files)}', False),
        (f'Database:  {db_name} ({db_backend})', False),
        (f'Logging:   {LOG_DIR}', False),
        (f'Root dir:  {Path(__file__).parent.parent.parent}', False),
        (f'Python:    {executable}', False),
    ]
    if plugins:
        lines += [(f'Plugins:   {",".join(plugins)}', False)]
    if debug:
        lines += [('DEVELOPMENT MODE, DO NOT USE IN PRODUCTION!', True)]
    image = '''
┏━━━━━━━━━━┓
┃  ┌─·──╮  ┃
┃  │  O │  ┃
┃  │ ┌──╯  ┃
┃  └─┘     ┃
┗━━━┯━┯━━━━┛
    ╰─╯
    '''.strip().split(
        '\n'
    )
    img_width = len(image[0])
    image[-1] += ' ' * (img_width - len(image[-1]))
    image += [' ' * img_width for _ in repeat(None, (len(lines) - len(image)))]

    lines = [(f'{image[n]}  {line[0]}', line[1]) for n, line in enumerate(lines)]

    size = max(len(line[0]) for line in lines) + 4
    start_box(size)
    for line in lines:
        print_line(line[0], box=True, bold=line[1], size=size)
    end_box(size)
예제 #5
0
파일: utils.py 프로젝트: vmx/pretalx
def log_initial(*, debug, config_files, db_name, db_backend, LOG_DIR, plugins):
    from pretalx.common.console import start_box, end_box, print_line
    from pretalx import __version__

    mode = 'development' if debug else 'production'
    lines = [
        (f'This is pretalx v{__version__} calling, running in {mode} mode.', True),
        ('', False),
        (f'Settings:', True),
        (f'Read from: {", ".join(config_files)}', False),
        (f'Database:  {db_name} ({db_backend})', False),
        (f'Logging:   {LOG_DIR}', False),
    ]
    if plugins:
        lines += [(f'Plugins:   {",".join(plugins)}', False)]
    else:
        lines += [('', False)]
    image = '''
┏━━━━━━━━━━┓
┃  ┌─·──╮  ┃
┃  │  O │  ┃
┃  │ ┌──╯  ┃
┃  └─┘     ┃
┗━━━┯━┯━━━━┛
    ╰─╯
    '''.strip().split(
        '\n'
    )
    img_width = len(image[0])
    image[-1] += ' ' * (img_width - len(image[-1]))
    image += [' ' * img_width for _ in range((len(lines) - len(image)))]

    lines = [(f'{image[n]}  {lines[n][0]}', lines[n][1]) for n in range(len(lines))]

    size = max(len(line[0]) for line in lines) + 4
    start_box(size)
    for line in lines:
        print_line(line[0], box=True, bold=line[1], size=size)
    end_box(size)
예제 #6
0
def test_print_line_does_not_barf(box, bold, color, size):
    print_line("Test", box=box, bold=bold, color=color, size=size)