From 17603d6c878016c67ac95f40fb4174972ae8f15e Mon Sep 17 00:00:00 2001 From: FrantiĊĦek Zatloukal Date: Jul 03 2020 07:00:18 +0000 Subject: Provide ipython debug entry point in the cli --- diff --git a/oraculum/cli.py b/oraculum/cli.py index 7cdc21a..e0755f7 100644 --- a/oraculum/cli.py +++ b/oraculum/cli.py @@ -18,6 +18,7 @@ # Josef Skladanka import os +import sys from argparse import ArgumentParser from alembic.config import Config @@ -77,10 +78,25 @@ def sync(): for r in CACHE._refreshers: CACHE._refresh(r) +def debug(): + print("Launching oraculum in debug mode...") + import oraculum + oraculum.main.register_cache_providers() + try: + from IPython import embed + from traitlets.config import get_config + except ImportError: + print("Make sure you have IPython installed for debug mode to work...") + sys.exit(1) + + c = get_config() + c.InteractiveShellEmbed.colors = "Linux" + c.InteractiveShell.pdb = True + embed(config=c) def main(): parser = ArgumentParser() - parser.add_argument("command", choices=['init_db', 'upgrade_db', 'sync'], help='Available commands') + parser.add_argument("command", choices=['init_db', 'upgrade_db', 'sync', 'debug'], help='Available commands') args = parser.parse_args() globals()[args.command]()