コード例 #1
0
def serve_app(app, path="", debug=False):

    # Turn off werkzeug  logging as it's very noisy

    aps_log = logging.getLogger('werkzeug')
    aps_log.setLevel(logging.ERROR)

    # Set SPA logging level (if needed)

    log.setLevel(logging.INFO)

    # When running in a Docker container the internal port
    # is mapped onto a host port. Use the env variables passed
    # in to the container to determin the host URL.

    port = int(os.environ.get("PORT", 8060))
    hostname = os.environ.get("HOST_HOSTNAME", "localhost")
    hostport = os.environ.get("HOST_HOSTPORT", "8050")

    print(f' * Visit http://{hostname}:{hostport}{path}')

    app.run_server(debug=debug,
                   host='0.0.0.0',
                   port=port,
                   threaded=False,
                   dev_tools_serve_dev_bundles=True)
コード例 #2
0
ファイル: googios.py プロジェクト: quasipedia/googios
def modify_logger(cli, config):
    '''Modify the logger so as '''
    if cli['--echo']:
        return
    log.removeHandler(log_stream_handler)
    log_level = config['log.level']
    log_dir = config['log.directory']
    log_fname = os.path.join(log_dir, '{}.log'.format(config['roster.name']))
    log_file_handler = logging.FileHandler(log_fname)
    log_file_handler.setFormatter(log_format)
    log.addHandler(log_file_handler)
    log.setLevel(log_level)
コード例 #3
0
def main():
    args = parse_argument()
    byte_word = args.word.encode('utf-8')
    log.info('検索語: %s' % args.word)
    log.info('検索語のバイト長: %d' % len(byte_word))

    if args.measure:
        log.setLevel(logging.ERROR)

    with args.data() as blob:
        results = brute_force_search(blob, byte_word)

    for result in results:
        log.debug(result.decode('utf-8').strip())
    log.info('検索結果: %d 件' % len(results))
コード例 #4
0
def main():
    args = parse_argument()
    byte_word = args.word.encode('utf-8')
    log.info('検索語: %s' % args.word)
    log.info('検索語のバイト長: %d' % len(byte_word))

    if args.measure:
        log.setLevel(logging.ERROR)

    with args.data() as blob:
        table = make_qs_table(byte_word)
        results = boyer_moore_sunday_search(blob, byte_word, table)

    for result in results:
        log.debug(result.decode('utf-8').strip())
    log.info('検索結果: %d 件' % len(results))
コード例 #5
0
    log.info('ループ回数: %d' % cnt)
    return results


def main():
    args = parse_argument()
    byte_word = args.word.encode('utf-8')
    log.info('検索語: %s' % args.word)
    log.info('検索語のバイト長: %d' % len(byte_word))

    if args.measure:
        log.setLevel(logging.ERROR)

    with args.data() as blob:
        results = brute_force_search(blob, byte_word)

    for result in results:
        log.debug(result.decode('utf-8').strip())
    log.info('検索結果: %d 件' % len(results))


if __name__ == '__main__':
    args = parse_argument()
    if args.measure:
        setup = 'from __main__ import main'
        sec = timeit.repeat('main()', setup=setup, repeat=3, number=5)
        log.setLevel(logging.INFO)
        log.info('平均実行時間: %f sec' % statistics.mean(sec))
    else:
        main()
コード例 #6
0
    return results


def main():
    args = parse_argument()
    byte_word = args.word.encode('utf-8')
    log.info('検索語: %s' % args.word)
    log.info('検索語のバイト長: %d' % len(byte_word))

    if args.measure:
        log.setLevel(logging.ERROR)

    with args.data() as blob:
        table = make_qs_table(byte_word)
        results = boyer_moore_sunday_search(blob, byte_word, table)

    for result in results:
        log.debug(result.decode('utf-8').strip())
    log.info('検索結果: %d 件' % len(results))


if __name__ == '__main__':
    args = parse_argument()
    if args.measure:
        setup = 'from __main__ import main'
        sec = timeit.repeat('main()', setup=setup, repeat=3, number=5)
        log.setLevel(logging.INFO)
        log.info('平均実行時間: %f sec' % statistics.mean(sec))
    else:
        main()