Python IPython.start_ipython() Examples
The following are 30
code examples of IPython.start_ipython().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
IPython
, or try the search function
.
Example #1
Source File: shell.py From python-libmaas with GNU Affero General Public License v3.0 | 7 votes |
def _run_interactive(namespace, descriptions): # We at a fully interactive terminal — i.e. stdin AND stdout are # connected to the TTY — so display some introductory text... banner = ["{automagenta}Welcome to the MAAS shell.{/automagenta}"] if len(descriptions) > 0: banner += ["", "Predefined objects:", ""] wrap = textwrap.TextWrapper(60, " ", " ").wrap sortkey = lambda name: (name.casefold(), name) for name in sorted(descriptions, key=sortkey): banner.append(" {autoyellow}%s{/autoyellow}:" % name) banner.extend(wrap(descriptions[name])) banner.append("") for line in banner: print(colorized(line)) # ... then start IPython, or the plain familiar Python REPL if # IPython is not installed. try: import IPython except ImportError: code.InteractiveConsole(namespace).interact(" ") else: IPython.start_ipython(argv=[], display_banner=False, user_ns=namespace)
Example #2
Source File: helper.py From sisyphus with Mozilla Public License 2.0 | 6 votes |
def connect(args): if len(args.argv) == 1: connect_file = args.argv[0] else: files = glob("ipython-kernel-*.json") files = [(os.path.getmtime(i), i) for i in files] files.sort() if len(files) > 0: connect_file = files[-1][1] else: connect_file = None assert connect_file and os.path.isfile(connect_file), "No connection file found" argv = [] argv.append("console") argv.append("--existing=%s" % os.path.abspath(connect_file)) logging.info("Connect to %s" % connect_file) import IPython IPython.start_ipython(argv=argv)
Example #3
Source File: command_line.py From clearly with MIT License | 6 votes |
def client(**kwargs): """Start a REPL shell, with an already configured Clearly Client `clearlycli`. \b HOST: The host where Clearly Server is running, default localhost PORT: The port where Clearly Server is running, default 12223 """ from clearly.client import ClearlyClient, ModeTask, ModeWorker share = dict( clearlycli=ClearlyClient(**{k: v for k, v in kwargs.items() if v}), ModeTask=ModeTask, ModeWorker=ModeWorker, ) # the first option was bpython, but unfortunately it is broken... # https://github.com/bpython/bpython/issues/758 # from bpython import embed # embed(dict(clearlycli=clearlycli)) import IPython from traitlets.config.loader import Config c = Config() c.TerminalInteractiveShell.banner1 = logo.render('client') + '\n' c.TerminalInteractiveShell.banner2 = 'Clearly client is ready to use: clearlycli' IPython.start_ipython(argv=[], user_ns=share, config=c)
Example #4
Source File: shell.py From zeus with Apache License 2.0 | 6 votes |
def shell(): import IPython from zeus.app import app from zeus.config import db ctx = app.make_shell_context() ctx["app"].test_request_context().push() ctx["db"] = db # Import all models into the shell context ctx.update(db.Model._decl_class_registry) startup = os.environ.get("PYTHONSTARTUP") if startup and os.path.isfile(startup): with open(startup, "rb") as f: eval(compile(f.read(), startup, "exec"), ctx) IPython.start_ipython(user_ns=ctx, argv=[])
Example #5
Source File: repl.py From iota.py with MIT License | 6 votes |
def _start_repl(api: Iota) -> None: """ Starts the REPL. """ banner = ( 'IOTA API client for {uri} ({devnet}) ' 'initialized as variable `api`.\n' 'Type `help(api)` for list of API commands.'.format( devnet='devnet' if api.devnet else 'mainnet', uri=api.adapter.get_uri(), ) ) scope_vars = {'api': api} try: import IPython except ImportError: # IPython not available; use regular Python REPL. from code import InteractiveConsole InteractiveConsole(locals=scope_vars).interact(banner, '') else: print(banner) IPython.start_ipython(argv=[], user_ns=scope_vars)
Example #6
Source File: ocpshell.py From insights-core with Apache License 2.0 | 6 votes |
def main(): args = parse_args() archives = args.archives if args.debug: logging.basicConfig(level=logging.DEBUG) excludes = parse_exclude(args.exclude) if args.exclude else ["*.log"] conf = analyze(archives, excludes) # noqa F841 / unused var # import all the built-in predicates from insights.parsr.query import (lt, le, eq, gt, ge, isin, contains, # noqa: F403 startswith, endswith, ieq, icontains, istartswith, iendswith, # noqa: F403 matches, make_child_query) # noqa: F403 q = make_child_query # noqa: F405 import IPython from traitlets.config.loader import Config IPython.core.completer.Completer.use_jedi = False c = Config() c.TerminalInteractiveShell.banner1 = banner IPython.start_ipython([], user_ns=locals(), config=c)
Example #7
Source File: word2vec_optimized.py From hands-detection with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #8
Source File: shell.py From rotest with MIT License | 5 votes |
def main(): django.setup() create_result() print("Creating client") BaseResource._SHELL_CLIENT = ClientResourceManager() print("""Done! You can now lock resources and run tests, e.g. resource1 = ResourceClass.lock(skip_init=True, name='resource_name') resource2 = ResourceClass.lock(name='resource_name', config='config.json') shared_data['resource'] = resource1 run_test(ResourceBlock, parameter=5) run_test(ResourceBlock.params(parameter=6), resource=resource2) run_test(SomeTestCase, debug=True) """) startup_commands = [IMPORT_BLOCK_UTILS, IMPORT_RESOURCE_LOADER] startup_commands.append("imported_resources = get_resources();" "print('Importing resources:'); " "print(', '.join(imported_resources.keys()));" "globals().update(imported_resources)") startup_commands.extend(SHELL_STARTUP_COMMANDS) try: IPython.start_ipython(["-i", "--no-banner", "-c", ";".join(startup_commands)]) finally: print("Releasing locked resources...") BaseResource._SHELL_CLIENT.disconnect()
Example #9
Source File: word2vec.py From hands-detection with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #10
Source File: word2vec_optimized.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #11
Source File: word2vec.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #12
Source File: word2vec_optimized.py From object_detection_kitti with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #13
Source File: word2vec.py From object_detection_kitti with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #14
Source File: word2vec_optimized.py From object_detection_with_tensorflow with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #15
Source File: word2vec.py From object_detection_with_tensorflow with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #16
Source File: word2vec_optimized.py From HumanRecognition with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #17
Source File: word2vec.py From HumanRecognition with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #18
Source File: word2vec_optimized.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #19
Source File: word2vec.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #20
Source File: flask_shell_ipython.py From flask-shell-ipython with MIT License | 5 votes |
def shell(ipython_args): """Runs a shell in the app context. Runs an interactive Python shell in the context of a given Flask application. The application will populate the default namespace of this shell according to it's configuration. This is useful for executing small snippets of management code without having to manually configuring the application. """ import IPython from IPython.terminal.ipapp import load_default_config from traitlets.config.loader import Config from flask.globals import _app_ctx_stack app = _app_ctx_stack.top.app if 'IPYTHON_CONFIG' in app.config: config = Config(app.config['IPYTHON_CONFIG']) else: config = load_default_config() config.TerminalInteractiveShell.banner1 = '''Python %s on %s IPython: %s App: %s [%s] Instance: %s''' % (sys.version, sys.platform, IPython.__version__, app.import_name, app.env, app.instance_path) IPython.start_ipython( argv=ipython_args, user_ns=app.make_shell_context(), config=config, )
Example #21
Source File: word2vec_optimized.py From DOTA_models with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #22
Source File: word2vec.py From TensorFlow-Playground with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #23
Source File: word2vec_optimized.py From TensorFlow-Playground with MIT License | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #24
Source File: helper.py From sisyphus with Mozilla Public License 2.0 | 5 votes |
def console(args): """ Start an interactive ipython console """ user_ns = {'tk': sisyphus.toolkit, 'config_files': args.config_files, } if args.load: jobs = [sisyphus.toolkit.load_job(i) for i in args.load] user_ns['jobs'] = jobs for i, job in enumerate(jobs): print("jobs[%i]: %s" % (i, job)) elif not args.not_load_config: load_configs(args.config_files) # TODO Update welcome message welcome_msg = """ Info: IPCompleter.greedy = True is set to True. This allows to auto complete lists and dictionaries entries, but may evaluates functions on tab. Enter tk? for help""" import IPython from traitlets.config.loader import Config c = Config() c.InteractiveShell.banner2 = welcome_msg c.IPCompleter.greedy = True c.InteractiveShellApp.exec_lines = ['%rehashx'] + args.commands IPython.start_ipython(config=c, argv=[], user_ns=user_ns) # ### Notebook stuff, needs more testing # TODO currently not working
Example #25
Source File: manager_ui.py From sisyphus with Mozilla Public License 2.0 | 5 votes |
def open_console(self, w, given_commands=None): """ Start an interactive ipython console """ import sisyphus user_ns = {'tk': sisyphus.toolkit, 'config_files': self.args.config_files, } # TODO Update welcome message welcome_msg = """ Info: IPCompleter.greedy = True is set to True. This allows to auto complete lists and dictionaries entries, but may evaluates functions on tab. Enter tk? for help""" run_commands = [] if given_commands: for c in given_commands: run_commands.append('print("Run command:", %s)' % repr(c)) run_commands.append(c) import IPython from traitlets.config.loader import Config c = Config() c.InteractiveShellApp.exec_lines = ['%rehashx'] + run_commands c.InteractiveShell.confirm_exit = False c.IPCompleter.greedy = True c.InteractiveShell.banner2 = welcome_msg with self.pause(): IPython.start_ipython(config=c, argv=[], user_ns=user_ns)
Example #26
Source File: shell.py From insights-core with Apache License 2.0 | 5 votes |
def start_session(paths, change_directory=False, __coverage=None): __cwd = os.path.abspath(os.curdir) def callback(brokers): models = Holder() for i, (path, broker) in enumerate(brokers): avail = _get_available_models(broker) if paths: if len(paths) > 1: models[paths[i]] = Models(broker, avail, __cwd, path, __coverage) else: models = Models(broker, avail, __cwd, path, __coverage) else: models = Models(broker, avail, __cwd, path, __coverage) if change_directory and len(brokers) == 1: __working_path, _ = brokers[0] os.chdir(__working_path) # disable jedi since it won't autocomplete for objects with__getattr__ # defined. IPython.core.completer.Completer.use_jedi = False __cfg = Config() __cfg.TerminalInteractiveShell.banner1 = Models.__doc__ __ns = {} __ns.update(globals()) __ns.update({"models": models}) IPython.start_ipython([], user_ns=__ns, config=__cfg) with_brokers(paths, callback) if change_directory: os.chdir(__cwd)
Example #27
Source File: word2vec.py From deep_image_model with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #28
Source File: word2vec_optimized.py From deep_image_model with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #29
Source File: word2vec.py From Gun-Detector with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)
Example #30
Source File: word2vec_optimized.py From Gun-Detector with Apache License 2.0 | 5 votes |
def _start_shell(local_ns=None): # An interactive shell is useful for debugging/development. import IPython user_ns = {} if local_ns: user_ns.update(local_ns) user_ns.update(globals()) IPython.start_ipython(argv=[], user_ns=user_ns)