Exemplo n.º 1
0
def cli():
    parser = argparse.ArgumentParser(
        description='A simple Teamspeak stats-generator,'
        ' based solely on server-logs',
        argument_default=argparse.SUPPRESS)
    parser.add_argument('-c', '--config', type=str, help='path to config')
    parser.add_argument('--idmap', type=str, help='path to id_map')
    parser.add_argument('-l',
                        '--log',
                        type=str,
                        help='path to your logfile(s). '
                        'pass a directory to use all logfiles inside it')
    parser.add_argument('-o',
                        '--output',
                        type=str,
                        help='path to the output-file')
    parser.add_argument('-d',
                        '--debug',
                        help='debug mode',
                        action='store_true')
    parser.add_argument('-ds',
                        '--debugstdout',
                        help='write debug output to stdout',
                        action='store_true')
    parser.add_argument('-nod',
                        '--noonlinedc',
                        help='don\'t add connect until now to onlinetime',
                        action='store_false',
                        dest='onlinedc')
    parser.add_argument('-t',
                        '--template',
                        type=str,
                        help='path to custom template')
    parser.add_argument('-dtf',
                        '--datetimeformat',
                        type=str,
                        help='format of date/time-values (datetime.strftime)')
    parser.add_argument(
        '-otth',
        '--onlinetimethreshold',
        type=int,
        help='threshold for displaying onlinetime (in seconds)')
    parser.add_argument(
        '-lsa',
        '--lastseenabsolute',
        help='render last seen timestamp absolute (instead of relative)',
        action='store_false',
        dest='lastseenrelative')
    options = parser.parse_args()
    if 'config' in options:
        configuration = config.load(options.config)
    else:
        configuration = config.load()
    for option, value in vars(options).items():
        configuration.set('General', option, str(value))
    main(configuration)
Exemplo n.º 2
0
def cli():
    parser = argparse.ArgumentParser(
        description='A simple Teamspeak stats-generator, based on server-logs',
        argument_default=argparse.SUPPRESS
    )
    parser.add_argument(
        '-c', '--config',
        type=str, help='path to config'
    )
    parser.add_argument(
        '--idmap', type=str, help='path to id_map'
    )
    parser.add_argument(
        '-l', '--log',
        type=str, help='path to your logfile(s)'
    )
    parser.add_argument(
        '-o', '--output',
        type=str, help='path to the output-file'
    )
    parser.add_argument(
        '-d', '--debug',
        help='debug mode', action='store_true'
    )
    parser.add_argument(
        '-nod', '--noonlinedc',
        help='don\'t add connect until now to onlinetime',
        action='store_false', dest='onlinedc'
    )
    parser.add_argument(
        '-t', '--template',
        type=str, help='path to custom template'
    )
    parser.add_argument(
        '-dtf', '--datetimeformat',
        type=str, help='format of date/time-values (datetime.strftime)'
    )
    parser.add_argument(
        '-otth', '--onlinetimethreshold',
        type=int, help='threshold for displaying onlinetime (in seconds)'
    )
    options = parser.parse_args()
    if 'config' in options:
        configuration = config.load(options.config)
    else:
        configuration = config.load()
    for option, value in vars(options).items():
        configuration.set('General', option, str(value))
    main(configuration)
Exemplo n.º 3
0
def test_read():
    config = load(path='tsstats/tests/res/config.ini')
    # test defaults
    assert not config.getboolean('General', 'debug')
    # test written values
    assert config.get('General', 'log') == 'tsstats/tests/res/test.log'
    assert config.get('General', 'output') == 'tsstats/tests/res/output.html'
Exemplo n.º 4
0
def test_config(config):
    create_config({
        'idmap': 'tsstats/tests/res/id_map.json',
        'log': 'tsstats/tests/res/test.log',
        'output': 'output.html',
        'debug': 'true',
        'onlinedc': 'false'
    })
    configuration = load(configpath)
    assert configuration.get('General', 'idmap') ==\
        'tsstats/tests/res/id_map.json'
    assert configuration.get('General', 'log') == 'tsstats/tests/res/test.log'
    assert configuration.get('General', 'output') == 'output.html'
    assert configuration.getboolean('General', 'debug') is True
    assert configuration.getboolean('General', 'onlinedc') is False
Exemplo n.º 5
0
def config():
    return load()