Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Minor cosmetic improvements to REPL script.
Browse files Browse the repository at this point in the history
- Vanilla Python no longer outputs "now exiting InteractiveConsole..." on exit.
- IPython now respects profile settings.

(`IPython.embed()` is meant for debugging purposes; `IPython.start_ipython()` is part of the public API;
see https://ipython.readthedocs.io/en/stable/interactive/reference.html\#embedding for more info.)
  • Loading branch information
todofixthis committed Feb 16, 2018
1 parent d9d816b commit dc0ab5f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions iota/bin/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,26 @@ def _start_repl(api):
"""
Starts the REPL.
"""
_banner = (
banner = (
'IOTA API client for {uri} ({testnet}) initialized as variable `api`.\n'
'Type `help(api)` for list of API commands.'.format(
testnet = 'testnet' if api.testnet else 'mainnet',
uri = api.adapter.get_uri(),
)
)

scope_vars = {'api': api}

try:
# noinspection PyUnresolvedReferences
import IPython
except ImportError:
# IPython not available; use regular Python REPL.
from code import InteractiveConsole
InteractiveConsole(locals={'api': api}).interact(_banner)
InteractiveConsole(locals=scope_vars).interact(banner, '')
else:
# Launch IPython REPL.
IPython.embed(header=_banner)
print(banner)
IPython.start_ipython(argv=[], user_ns=scope_vars)


def main():
Expand Down

0 comments on commit dc0ab5f

Please sign in to comment.