Esempio n. 1
0
def main() -> None:
    # Load config.py
    config_filepath = os.path.join(conf.get_data_dir(), 'config.py')
    if os.path.isfile(config_filepath):
        conf.load_overrides_from_file(config_filepath)
    # Run
    try:
        run(sys.argv[1:])
    except (KeyboardInterrupt, Exception) as exc:
        from .file_utils import get_dated_tmp_path
        import traceback
        exc_filepath = get_dated_tmp_path('exception')
        with open(exc_filepath, 'w') as f:
            f.write('======= Exception ====\n')
            f.write(str(exc) + '\n\n')
            f.write('======= Traceback ====\n')
            f.write(traceback.format_exc())
        if isinstance(exc, PheWebError):
            print('\n\n')
            print(exc)
        elif isinstance(exc, KeyboardInterrupt):
            print('\nInterrupted')
        elif isinstance(exc, SyntaxError):
            print(repr(exc))
        else:
            print('\nAn exception occurred')
        print('(Details in {})\n'.format(exc_filepath))
        exit(1)
Esempio n. 2
0
def configure(argv:List[str]) -> None:
    for i, arg in enumerate(argv):
        if '=' not in arg: break
        k,v = arg.split('=', 1)
        try: v = json.loads(v)
        except json.JSONDecodeError: pass
        conf.set_override(k, v)
    else:
        print(json.dumps(conf.overrides, indent=2))
        return
    run(argv[i:])
Esempio n. 3
0
def configure(argv):
    from .conf_utils import conf
    import json
    for i, arg in enumerate(argv):
        if '=' not in arg: break
        k,v = arg.split('=', 1)
        try: conf[k] = json.loads(v)
        except json.JSONDecodeError: conf[k] = v
    else:
        print(conf)
        exit(1)
    run(argv[i:])
Esempio n. 4
0
def configure(argv):
    from .conf_utils import conf
    import json
    for i, arg in enumerate(argv):
        if '=' not in arg: break
        k, v = arg.split('=', 1)
        try:
            conf[k] = json.loads(v)
        except json.JSONDecodeError:
            conf[k] = v
    else:
        print(conf)
        exit(1)
    run(argv[i:])
Esempio n. 5
0
def main():
    from .utils import PheWebError
    try:
        run(sys.argv[1:])
    except (KeyboardInterrupt, Exception) as exc:
        from .file_utils import get_dated_tmp_path
        import traceback
        exc_filepath = get_dated_tmp_path('exception')
        with open(exc_filepath, 'w') as f:
            f.write(traceback.format_exc())
        if isinstance(exc, PheWebError): print(exc)
        elif isinstance(exc, KeyboardInterrupt): print('\nInterrupted')
        else: print('\nAn exception occurred')
        print('(Details in {})\n'.format(exc_filepath))
        exit(1)
Esempio n. 6
0
def main():
    from .utils import PheWebError
    try:
        run(sys.argv[1:])
    except (KeyboardInterrupt, Exception) as exc:
        from .file_utils import get_dated_tmp_path
        import traceback
        exc_filepath = get_dated_tmp_path('exception')
        with open(exc_filepath, 'w') as f:
            f.write('======= Exception ====\n')
            f.write(str(exc) + '\n\n')
            f.write('======= Traceback ====\n')
            f.write(traceback.format_exc())
        if isinstance(exc, PheWebError): print(exc)
        elif isinstance(exc, KeyboardInterrupt): print('\nInterrupted')
        elif isinstance(exc, SyntaxError): print(repr(exc))
        else: print('\nAn exception occurred')
        print('(Details in {})\n'.format(exc_filepath))
        exit(1)
Esempio n. 7
0
def serve(argv:List[str]) -> None:
    from pheweb.serve.run import run
    run(argv)
Esempio n. 8
0
def serve(argv):
    from pheweb.serve.run import run
    run(argv)
Esempio n. 9
0
def help(argv):
    run(argv[0:1] + ['-h'])
Esempio n. 10
0
def ipdb(argv):
    enable_ipdb()
    run(argv)
Esempio n. 11
0
def quick(argv):
    enable_quick()
    run(argv)
Esempio n. 12
0
def debug(argv):
    enable_debug()
    run(argv)
Esempio n. 13
0
def help(argv):
    run(argv[0:1] + ['-h'])
Esempio n. 14
0
def ipdb(argv):
    enable_ipdb()
    run(argv)
Esempio n. 15
0
def serve(argv):
    from pheweb.serve.run import run
    run(argv)