diff -Nru jupyter-console-5.0.0/debian/changelog jupyter-console-5.2.0/debian/changelog --- jupyter-console-5.0.0/debian/changelog 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/changelog 2017-10-25 22:43:42.000000000 +0000 @@ -1,3 +1,20 @@ +jupyter-console (5.2.0-1) unstable; urgency=medium + + * New upstream version + * Add uversionmangle rule to d/watch to correctly sort beta versions + * Update Standards-Version to 4.1.1 + * Add a dependency on jupyter-core for jupyter-console, to ensure that + the jupyter console subcommand is available. + * Use python3 sphinx for documentation, add ${sphinx:Built-Using} to the + documentation package + * Update years, use https URL in d/copyright + * Convert from git-dpm to gbp patches-unapplied format + * Patch out use of extension sphinxcontrib_github_alt in the documentation + * Add Testsuite: autopkgtest-pkg-python to d/control (only an autodep8 + module-can-be-imported tested is performed) + + -- Gordon Ball Thu, 26 Oct 2017 00:43:42 +0200 + jupyter-console (5.0.0-1) unstable; urgency=medium * Initial release. (Closes: #842825) diff -Nru jupyter-console-5.0.0/debian/control jupyter-console-5.2.0/debian/control --- jupyter-console-5.0.0/debian/control 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/control 2017-10-25 21:36:15.000000000 +0000 @@ -3,24 +3,23 @@ Uploaders: Gordon Ball Section: python Priority: optional -Standards-Version: 3.9.8 +Standards-Version: 4.1.1 Homepage: https://github.com/jupyter/jupyter_console Build-Depends: debhelper (>= 10), dh-python, - ipython, - ipython3, python-all, - python-pytest, + python-ipython, python-setuptools, - python-sphinx, - python-sphinx-rtd-theme, python3-all, - python3-pytest, - python3-setuptools + python3-ipython, + python3-setuptools, + python3-sphinx, + python3-sphinx-rtd-theme, X-Python-Version: >= 2.7 X-Python3-Version: >= 3.3 Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/jupyter-console.git Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/jupyter-console.git +Testsuite: autopkgtest-pkg-python Package: python-jupyter-console Architecture: all @@ -45,7 +44,8 @@ Section: utils Depends: python3-jupyter-console (= ${binary:Version}), ${misc:Depends}, - ${python3:Depends} + ${python3:Depends}, + jupyter-core Description: Jupyter terminal client (script) Terminal-based console frontend for Jupyter kernels, like ipython but with support for non-python kernels. @@ -56,6 +56,7 @@ Architecture: all Section: doc Depends: ${misc:Depends}, ${sphinxdoc:Depends} +Built-Using: ${sphinx:Built-Using} Description: Jupyter terminal client (documentation) Terminal-based console frontend for Jupyter kernels, like ipython but with support for non-python kernels. diff -Nru jupyter-console-5.0.0/debian/copyright jupyter-console-5.2.0/debian/copyright --- jupyter-console-5.0.0/debian/copyright 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/copyright 2017-10-25 21:36:15.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0 +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0 Upstream-Name: jupyter_console Files: * @@ -6,7 +6,7 @@ License: BSD-3-clause Files: debian/* -Copyright: 2016 Gordon Ball +Copyright: 2016-2017 Gordon Ball License: BSD-3-clause License: BSD-3-clause diff -Nru jupyter-console-5.0.0/debian/gbp.conf jupyter-console-5.2.0/debian/gbp.conf --- jupyter-console-5.0.0/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ jupyter-console-5.2.0/debian/gbp.conf 2017-10-25 21:36:15.000000000 +0000 @@ -0,0 +1,7 @@ +[DEFAULT] +upstream-branch = upstream +debian-branch = master +upstream-tag = upstream/%(version)s +debian-tag = debian/%(version)s +sign-tags = True +pristine-tar = True diff -Nru jupyter-console-5.0.0/debian/.git-dpm jupyter-console-5.2.0/debian/.git-dpm --- jupyter-console-5.0.0/debian/.git-dpm 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/.git-dpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# see git-dpm(1) from git-dpm package -23dd3f9b13ce1ea8d6fbf2dd924b786768e0bc40 -23dd3f9b13ce1ea8d6fbf2dd924b786768e0bc40 -08236a52dc46cccef83726b75e0033b5938be29f -08236a52dc46cccef83726b75e0033b5938be29f -jupyter-console_5.0.0.orig.tar.gz -03130aadbcc0b127d117d1a552c79bc0cd13ae72 -26119 diff -Nru jupyter-console-5.0.0/debian/patches/0001-Unconditionally-use-setuptools-so-that-dependencies-.patch jupyter-console-5.2.0/debian/patches/0001-Unconditionally-use-setuptools-so-that-dependencies-.patch --- jupyter-console-5.0.0/debian/patches/0001-Unconditionally-use-setuptools-so-that-dependencies-.patch 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/patches/0001-Unconditionally-use-setuptools-so-that-dependencies-.patch 2017-10-25 21:36:15.000000000 +0000 @@ -1,4 +1,3 @@ -From 23dd3f9b13ce1ea8d6fbf2dd924b786768e0bc40 Mon Sep 17 00:00:00 2001 From: Gordon Ball Date: Tue, 1 Nov 2016 15:42:31 +0100 Subject: Unconditionally use setuptools so that dependencies are detected diff -Nru jupyter-console-5.0.0/debian/patches/0002-Disable-sphinxcontrib_github_alt-in-documentation.patch jupyter-console-5.2.0/debian/patches/0002-Disable-sphinxcontrib_github_alt-in-documentation.patch --- jupyter-console-5.0.0/debian/patches/0002-Disable-sphinxcontrib_github_alt-in-documentation.patch 1970-01-01 00:00:00.000000000 +0000 +++ jupyter-console-5.2.0/debian/patches/0002-Disable-sphinxcontrib_github_alt-in-documentation.patch 2017-10-25 21:36:15.000000000 +0000 @@ -0,0 +1,22 @@ +From: Gordon Ball +Date: Wed, 23 Aug 2017 21:17:15 +0000 +Subject: Disable sphinxcontrib_github_alt in documentation + +This extension is unavailable and causes the documentation build to +fail. +--- + docs/conf.py | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/docs/conf.py b/docs/conf.py +index 1a432bf..e1d6814 100644 +--- a/docs/conf.py ++++ b/docs/conf.py +@@ -44,7 +44,6 @@ if os.environ.get('READTHEDOCS', ''): + # ones. + extensions = [ + 'sphinx.ext.intersphinx', +- 'sphinxcontrib_github_alt', + ] + + github_project_url = "https://github.com/jupyter/jupyter_console" diff -Nru jupyter-console-5.0.0/debian/patches/series jupyter-console-5.2.0/debian/patches/series --- jupyter-console-5.0.0/debian/patches/series 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/patches/series 2017-10-25 21:36:15.000000000 +0000 @@ -1 +1,2 @@ 0001-Unconditionally-use-setuptools-so-that-dependencies-.patch +0002-Disable-sphinxcontrib_github_alt-in-documentation.patch diff -Nru jupyter-console-5.0.0/debian/watch jupyter-console-5.2.0/debian/watch --- jupyter-console-5.0.0/debian/watch 2016-11-01 14:49:53.000000000 +0000 +++ jupyter-console-5.2.0/debian/watch 2017-10-25 21:36:15.000000000 +0000 @@ -1,2 +1,3 @@ version=3 +opts=uversionmangle=s/b/~b/,dversionmangle=s/~b/b/ \ http://pypi.debian.net/jupyter_console/jupyter_console-(.*)\.tar\.gz diff -Nru jupyter-console-5.0.0/docs/changelog.rst jupyter-console-5.2.0/docs/changelog.rst --- jupyter-console-5.0.0/docs/changelog.rst 2016-07-05 16:04:11.000000000 +0000 +++ jupyter-console-5.2.0/docs/changelog.rst 2017-08-21 10:27:33.000000000 +0000 @@ -3,25 +3,53 @@ A summary of changes in Jupyter console releases. +5.2 +--- + +- When using a kernel that the console did not start, exiting with Ctrl-D now + leaves it running. :ghpull:`127` +- Added Ctrl-\\ shortcut to quit the console. :ghpull:`130` +- Input prompt numbers are now updated when another frontend has executed + code in the same kernel. :ghpull:`119` +- Fix setting next input with newer versions of prompt_toolkit. :ghpull:`123` +- Ensure history entries are unicode, not bytes, on Python 2. :ghpull:`122` + +5.1 +--- + +- New ``ZMQTerminalInteractiveShell.true_color`` config option to use 24-bit + colour. +- New ``ZMQTerminalInteractiveShell.confirm_exit`` config option to turn off + asking 'are you sure' on exit. +- New ``--simple-prompt`` flag to explicitly use the fallback mode without + prompt_toolkit. +- Fixed executing an empty input. +- Fixed formatting for code and outputs from other frontends executing code. +- Avoid using functions which will be removed in IPython 6. + 5.0 --- +5.0.0 +~~~~~ + Interactive Shell architecture ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- disinherit shell class from IPython Interactive Shell `#68 `_ - This separates jupyter_console's ZMQTerminalInteractiveShell from IPython's TerminalInteractiveShell and InteractiveShell classes. -- update SIGINT handler to not use the old interactive API shell `#80 `_ +- Disinherit shell class from IPython Interactive Shell (:ghpull:`68`). + This separates jupyter_console's ``ZMQTerminalInteractiveShell`` from + IPython's ``TerminalInteractiveShell`` and ``InteractiveShell`` classes. +- Update SIGINT handler to not use the old interactive API shell. :ghpull:`80` Image Handling improvement ^^^^^^^^^^^^^^^^^^^^^^^^^^ -- use PIL as default image handler `#79 `_ -- better indication of whether image data was handled `#77 `_ +- use PIL as default image handler :ghpull:`79` +- better indication of whether image data was handled :ghpull:`77` Prompts improvement ^^^^^^^^^^^^^^^^^^^ -- use prompt_toolkit 1.0 `#74 `_ -- don't use prompt_manager `#75 `_ -- remove ``colors_force`` flag that have no effects: `#88 `_ +- use prompt_toolkit 1.0 :ghpull:`74` +- don't use prompt_manager :ghpull:`75` +- remove ``colors_force`` flag that have no effects: :ghpull:`88` 4.1 --- diff -Nru jupyter-console-5.0.0/docs/conf.py jupyter-console-5.2.0/docs/conf.py --- jupyter-console-5.0.0/docs/conf.py 2016-03-10 18:38:25.000000000 +0000 +++ jupyter-console-5.2.0/docs/conf.py 2017-08-21 10:27:33.000000000 +0000 @@ -20,7 +20,13 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) + +# add repo root to sys.path +# docs_dir = root/docs +docsdir = os.path.abspath(os.path.dirname(__file__)) +reporoot = os.path.dirname(os.path.dirname(docsdir)) +sys.path.insert(0, reporoot) + if os.environ.get('READTHEDOCS', ''): # RTD doesn't use the Makefile, so re-run autogen_config.py here. @@ -38,8 +44,11 @@ # ones. extensions = [ 'sphinx.ext.intersphinx', + 'sphinxcontrib_github_alt', ] +github_project_url = "https://github.com/jupyter/jupyter_console" + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -152,7 +161,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +#html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -300,4 +309,14 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {'https://docs.python.org/3': None,} + +# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# otherwise, readthedocs.org uses their theme by default, so no need to specify it diff -Nru jupyter-console-5.0.0/docs/environment.yml jupyter-console-5.2.0/docs/environment.yml --- jupyter-console-5.0.0/docs/environment.yml 1970-01-01 00:00:00.000000000 +0000 +++ jupyter-console-5.2.0/docs/environment.yml 2016-09-12 15:49:27.000000000 +0000 @@ -0,0 +1,11 @@ +name: jupyterconsole +channels: + - conda-forge + - conda +dependencies: + - python=3 + - ipython + - jupyter_core + - jupyter_client + - sphinx + - sphinx_rtd_theme diff -Nru jupyter-console-5.0.0/docs/index.rst jupyter-console-5.2.0/docs/index.rst --- jupyter-console-5.0.0/docs/index.rst 2016-06-07 21:34:39.000000000 +0000 +++ jupyter-console-5.2.0/docs/index.rst 2017-01-11 13:27:41.000000000 +0000 @@ -6,6 +6,10 @@ pip install jupyter-console +If you want to use conda instead to perform your installation:: + + conda install -c conda-forge jupyter-console + And started with:: jupyter console diff -Nru jupyter-console-5.0.0/docs/release.rst jupyter-console-5.2.0/docs/release.rst --- jupyter-console-5.0.0/docs/release.rst 2016-06-07 21:36:55.000000000 +0000 +++ jupyter-console-5.2.0/docs/release.rst 2017-03-15 15:29:47.000000000 +0000 @@ -6,12 +6,6 @@ This document guides a maintainer through creating a release of the Jupyter console. -Check installed tools ---------------------- - -Review ``CONTRIBUTING.rst``. Make sure all the tools needed are properly -installed. - Clean the repository -------------------- @@ -51,7 +45,7 @@ .. code:: bash - python setup.py sdist --formats=zip,gztar + python setup.py sdist --formats=gztar python setup.py bdist_wheel #. You can now test the ``wheel`` and the ``sdist`` locally before uploading diff -Nru jupyter-console-5.0.0/docs/requirements.txt jupyter-console-5.2.0/docs/requirements.txt --- jupyter-console-5.0.0/docs/requirements.txt 2016-03-10 18:38:25.000000000 +0000 +++ jupyter-console-5.2.0/docs/requirements.txt 2017-08-21 10:27:33.000000000 +0000 @@ -1,2 +1,6 @@ --e git://github.com/ipython/ipython#egg=ipython --e . +ipython +-e ../. +jupyter_core +jupyter_client +sphinx +sphinxcontrib_github_alt diff -Nru jupyter-console-5.0.0/jupyter_console/app.py jupyter-console-5.2.0/jupyter_console/app.py --- jupyter-console-5.0.0/jupyter_console/app.py 2016-06-06 18:43:11.000000000 +0000 +++ jupyter-console-5.2.0/jupyter_console/app.py 2017-01-31 13:34:48.000000000 +0000 @@ -16,8 +16,7 @@ from traitlets import ( Dict, Any ) -from traitlets.config import catch_config_error -from IPython.utils.warn import error +from traitlets.config import catch_config_error, boolean_flag from jupyter_core.application import JupyterApp, base_aliases, base_flags, NoStart from jupyter_client.consoleapp import ( @@ -46,6 +45,11 @@ frontend_flags = dict(app_flags) # update full dict with frontend flags: flags.update(frontend_flags) +flags.update(boolean_flag( + 'simple-prompt', 'ZMQTerminalInteractiveShell.simple_prompt', + "Force simple minimal prompt using `raw_input`", + "Use a rich interactive prompt with prompt_toolkit" +)) # copy flags from mixin aliases = dict(base_aliases) @@ -120,8 +124,8 @@ if self.kernel_manager: self.kernel_manager.interrupt_kernel() else: - print("", file=sys.stderr) - error("Cannot interrupt kernels we didn't start.\n") + print("ERROR: Cannot interrupt kernels we didn't start.", + file = sys.stderr) else: # raise the KeyboardInterrupt if we aren't waiting for execution, # so that the interact loop advances, and prompt is redrawn, etc. diff -Nru jupyter-console-5.0.0/jupyter_console/completer.py jupyter-console-5.2.0/jupyter_console/completer.py --- jupyter-console-5.0.0/jupyter_console/completer.py 2016-06-06 18:43:11.000000000 +0000 +++ jupyter-console-5.2.0/jupyter_console/completer.py 2017-01-11 13:27:41.000000000 +0000 @@ -10,21 +10,9 @@ from Queue import Empty # Py 2 from traitlets.config import Configurable -from IPython.core.completer import IPCompleter -from ipython_genutils.py3compat import str_to_unicode, unicode_to_str, cast_bytes, cast_unicode from traitlets import Float -import IPython.utils.rlineimpl as readline -def _construct_readline_matches(code, cursor_pos, content): - cursor_start = content['cursor_start'] - matches = [ code[:cursor_start] + m for m in content['matches'] ] - if content["cursor_end"] < cursor_pos: - extra = code[content["cursor_end"]: cursor_pos] - matches = [m + extra for m in matches] - matches = [ unicode_to_str(m) for m in matches ] - return matches - -class ZMQCompleter(IPCompleter): +class ZMQCompleter(Configurable): """Client-side completion machinery. How it works: self.complete will be called multiple times, with @@ -39,11 +27,6 @@ self.shell = shell self.client = client self.matches = [] - # don't do any splitting client-side, - # rely on the kernel for that - self.splitter.delims = '\r\n' - if hasattr(self.readline, 'set_completer_delims'): - self.readline.set_completer_delims('\r\n') def complete_request(self, code, cursor_pos): # send completion request to kernel @@ -59,24 +42,4 @@ return {'matches': [], 'cursor_start': 0, 'cursor_end': 0, 'metadata': {}, 'status': 'ok'} - - def rlcomplete(self, text, state): - if state == 0: - line = str_to_unicode(readline.get_line_buffer()) - byte_cursor_pos = readline.get_endidx() - # get_endidx is a byte offset - # account for multi-byte characters to get correct cursor_pos - bytes_before_cursor = cast_bytes(line)[:byte_cursor_pos] - cursor_pos = len(cast_unicode(bytes_before_cursor)) - try: - content = self.complete_request(line, cursor_pos) - self.matches = _construct_readline_matches(line, cursor_pos, content) - except Empty: - #print('WARNING: Kernel timeout on tab completion.') - pass - - try: - return self.matches[state] - except IndexError: - return None diff -Nru jupyter-console-5.0.0/jupyter_console/ptshell.py jupyter-console-5.2.0/jupyter_console/ptshell.py --- jupyter-console-5.0.0/jupyter_console/ptshell.py 2016-07-05 16:01:09.000000000 +0000 +++ jupyter-console-5.2.0/jupyter_console/ptshell.py 2017-08-17 12:55:43.000000000 +0000 @@ -30,10 +30,11 @@ from . import __version__ from prompt_toolkit.completion import Completer, Completion +from prompt_toolkit.document import Document from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode from prompt_toolkit.filters import HasFocus, HasSelection, ViInsertMode, EmacsInsertMode from prompt_toolkit.history import InMemoryHistory -from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop +from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_output from prompt_toolkit.interface import CommandLineInterface from prompt_toolkit.key_binding.manager import KeyBindingManager from prompt_toolkit.key_binding.vi_state import InputMode @@ -43,7 +44,8 @@ from prompt_toolkit.styles import PygmentsStyle from pygments.styles import get_style_by_name -from pygments.lexers import LEXERS, find_lexer_class +from pygments.lexers import get_lexer_by_name +from pygments.util import ClassNotFound from pygments.token import Token def ask_yes_no(prompt, default=None, interrupt=None): @@ -87,13 +89,12 @@ from IPython.lib.lexers import IPython3Lexer return IPython3Lexer else: - for module_name, cls_name, aliases, _, _ in LEXERS.values(): - if name in aliases: - return find_lexer_class(cls_name) - - warn("No lexer found for language %r. Treating as plain text." % name) - from pygments.lexers.special import TextLexer - return TextLexer + try: + return get_lexer_by_name(name).__class__ + except ClassNotFound: + warn("No lexer found for language %r. Treating as plain text." % name) + from pygments.lexers.special import TextLexer + return TextLexer class JupyterPTCompleter(Completer): @@ -122,6 +123,7 @@ _execution_state = Unicode('') _pending_clearoutput = False _eventloop = None + own_kernel = False # Changed by ZMQTerminalIPythonApp editing_mode = Unicode('emacs', config=True, help="Shortcut style to use at the prompt. 'vi' or 'emacs'.", @@ -135,6 +137,13 @@ help="Override highlighting format for specific tokens" ) + true_color = Bool(False, config=True, + help=("Use 24bit colors instead of 256 colors in prompt highlighting. " + "If your terminal supports true color, the following command " + "should print 'TRUECOLOR' in orange: " + "printf \"\\x1b[38;2;255;100;0mTRUECOLOR\\x1b[0m\\n\"") + ) + history_load_length = Integer(1000, config=True, help="How many history items to load into memory" ) @@ -229,6 +238,14 @@ """ ) + + confirm_exit = Bool(True, config=True, + help="""Set to display confirmation dialog on exit. + You can always use 'exit' or 'quit', to force a + direct exit without any confirmation. + """ + ) + manager = Instance('jupyter_client.KernelManager', allow_none=True) client = Instance('jupyter_client.KernelClient', allow_none=True) def _client_changed(self, name, old, new): @@ -238,6 +255,10 @@ def _banner1_default(self): return "Jupyter Console {version}\n".format(version=__version__) + simple_prompt = Bool(False, + help="""Use simple fallback prompt. Features may be limited.""" + ).tag(config=True) + def __init__(self, **kwargs): # This is where traits with a config_key argument are updated # from the values on config. @@ -313,7 +334,7 @@ kernel_banner=self.kernel_info.get('banner', ''))) def init_prompt_toolkit_cli(self): - if 'JUPYTER_CONSOLE_TEST' in os.environ: + if self.simple_prompt or ('JUPYTER_CONSOLE_TEST' in os.environ): # Simple restricted interface for tests so we can find prompts with # pexpect. Multi-line input not supported. def prompt(): @@ -339,6 +360,10 @@ b.newline() return + # Pressing enter flushes any pending display. This also ensures + # the displayed execution_count is correct. + self.handle_iopub() + more, indent = self.check_complete(d.text) if (not more) and b.accept_action.is_returnable: @@ -350,13 +375,17 @@ def _(event): event.current_buffer.reset() + @kbmanager.registry.add_binding(Keys.ControlBackslash, filter=HasFocus(DEFAULT_BUFFER)) + def _(event): + raise EOFError + # Pre-populate history from IPython's history database history = InMemoryHistory() last_cell = u"" for _, _, cell in self.history_manager.get_tail(self.history_load_length, include_latest=True): # Ignore blank lines and consecutive duplicates - cell = cell.rstrip() + cell = cast_unicode_py2(cell.rstrip()) if cell and (cell != last_cell): history.append(cell) @@ -401,7 +430,10 @@ ) self._eventloop = create_eventloop() - self.pt_cli = CommandLineInterface(app, eventloop=self._eventloop) + self.pt_cli = CommandLineInterface(app, + eventloop=self._eventloop, + output=create_output(true_color=self.true_color), + ) def prompt_for_code(self): document = self.pt_cli.run(pre_run=self.pre_prompt, @@ -423,8 +455,12 @@ except SyntaxError: return False, "" else: - more = (code.splitlines()[-1] != "") - return more, "" + lines = code.splitlines() + if len(lines): + more = (lines[-1] != "") + return more, "" + else: + return False, "" def ask_exit(self): self.keep_running = False @@ -434,11 +470,19 @@ def pre_prompt(self): if self.next_input: - b = self.pt_cli.application.buffer - b.text = cast_unicode_py2(self.next_input) + # We can't set the buffer here, because it will be reset just after + # this. Adding a callable to pre_run_callables does what we need + # after the buffer is reset. + s = cast_unicode_py2(self.next_input) + def set_doc(): + self.pt_cli.application.buffer.document = Document(s) + if hasattr(self.pt_cli, 'pre_run_callables'): + self.pt_cli.pre_run_callables.append(set_doc) + else: + # Older version of prompt_toolkit; it's OK to set the document + # directly here. + set_doc() self.next_input = None - # Move the cursor to the end - b.cursor_position += b.document.get_end_of_document_position() def interact(self, display_banner=None): while self.keep_running: @@ -447,7 +491,8 @@ try: code = self.prompt_for_code() except EOFError: - if ask_yes_no('Do you really want to exit ([y]/n)?','y','n'): + if (not self.confirm_exit) \ + or ask_yes_no('Do you really want to exit ([y]/n)?','y','n'): self.ask_exit() else: @@ -455,7 +500,7 @@ self.run_cell(code, store_history=True) def mainloop(self): - self.keepkernel = False + self.keepkernel = not self.own_kernel # An extra layer of protection in case someone mashing Ctrl-C breaks # out of our internal code. while True: @@ -465,7 +510,8 @@ except KeyboardInterrupt: print("\nKeyboardInterrupt escaped interact()\n") - self._eventloop.close() + if self._eventloop: + self._eventloop.close() if self.keepkernel and not self.own_kernel: print('keeping kernel alive') elif self.keepkernel and self.own_kernel : @@ -635,6 +681,10 @@ msg_type = sub_msg['header']['msg_type'] parent = sub_msg["parent_header"] + # Update execution_count in case it changed in another session + if msg_type == "execute_input": + self.execution_count = int(sub_msg["content"]["execution_count"]) + 1 + if self.include_output(sub_msg): if msg_type == 'status': self._execution_state = sub_msg["content"]["execution_state"] @@ -665,6 +715,10 @@ if 'text/plain' not in format_dict: continue + # prompt_toolkit writes the prompt at a slightly lower level, + # so flush streams first to ensure correct ordering. + sys.stdout.flush() + sys.stderr.flush() self.print_out_prompt() text_repr = format_dict['text/plain'] if '\n' in text_repr: @@ -687,7 +741,7 @@ if not self.from_here(sub_msg): sys.stdout.write(self.other_output_prefix) sys.stdout.write('In [{}]: '.format(content['execution_count'])) - sys.stdout.write(content['code']) + sys.stdout.write(content['code']+'\n') elif msg_type == 'clear_output': if sub_msg["content"]["wait"]: diff -Nru jupyter-console-5.0.0/jupyter_console/_version.py jupyter-console-5.2.0/jupyter_console/_version.py --- jupyter-console-5.0.0/jupyter_console/_version.py 2016-07-05 16:15:46.000000000 +0000 +++ jupyter-console-5.2.0/jupyter_console/_version.py 2017-08-21 10:32:57.000000000 +0000 @@ -5,6 +5,6 @@ See PEP 440 https://www.python.org/dev/peps/pep-0440/ """ -version_info = (5, 0, 0, '') +version_info = (5, 2, 0) __version__ = '.'.join(map(str, version_info[:3])) + ''.join(version_info[3:]) diff -Nru jupyter-console-5.0.0/PKG-INFO jupyter-console-5.2.0/PKG-INFO --- jupyter-console-5.0.0/PKG-INFO 2016-07-05 16:16:44.000000000 +0000 +++ jupyter-console-5.2.0/PKG-INFO 2017-08-21 10:37:54.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: jupyter_console -Version: 5.0.0 +Version: 5.2.0 Summary: Jupyter terminal console Home-page: https://jupyter.org Author: Jupyter Development Team diff -Nru jupyter-console-5.0.0/README.md jupyter-console-5.2.0/README.md --- jupyter-console-5.0.0/README.md 2016-03-10 18:38:25.000000000 +0000 +++ jupyter-console-5.2.0/README.md 2017-01-11 13:27:41.000000000 +0000 @@ -1,14 +1,18 @@ # Jupyter Console [![Build Status](https://travis-ci.org/jupyter/jupyter_console.svg?branch=master)](https://travis-ci.org/jupyter/jupyter_console) -[![Documentation Status](http://readthedocs.org/projects/jupyter-console/badge/?version=latest)](http://jupyter-console.readthedocs.org/en/latest/?badge=latest) +[![Documentation Status](http://readthedocs.org/projects/jupyter-console/badge/?version=latest)](https://jupyter-console.readthedocs.io/en/latest/?badge=latest) A terminal-based console frontend for Jupyter kernels. This code is based on the single-process IPython terminal. -Install: +Install with pip: pip install jupyter-console +Install with conda: + + conda install -c conda-forge jupyter_console + Start: jupyter console @@ -17,9 +21,21 @@ jupyter console -h +Jupyter Console allows for console-based interaction with non-python +Jupyter kernels such as IJulia, IRKernel. + +To start the console with a particular kernel, ask for it by name:: + + jupyter console --kernel=julia-0.4 + +A list of available kernels can be seen with:: + + jupyter kernelspec list + + ## Resources - [Project Jupyter website](https://jupyter.org) -- [Documentation for Jupyter Console](http://jupyter-console.readthedocs.org/en/latest/) [[PDF](https://media.readthedocs.org/pdf/jupyter-console/latest/jupyter-notebook.pdf)] -- [Documentation for Project Jupyter](http://jupyter.readthedocs.org/en/latest/index.html) [[PDF](https://media.readthedocs.org/pdf/jupyter/latest/jupyter.pdf)] +- [Documentation for Jupyter Console](https://jupyter-console.readthedocs.io/en/latest/) [[PDF](https://media.readthedocs.org/pdf/jupyter-console/latest/jupyter-notebook.pdf)] +- [Documentation for Project Jupyter](https://jupyter.readthedocs.io/en/latest/index.html) [[PDF](https://media.readthedocs.org/pdf/jupyter/latest/jupyter.pdf)] - [Issues](https://github.com/jupyter/jupyter_console/issues) - [Technical support - Jupyter Google Group](https://groups.google.com/forum/#!forum/jupyter)