From 3a98b55af51d48a318ce6ca6765c5aa0ffc2da38 2015-03-25 23:54:39 From: Min RK Date: 2015-03-25 23:54:39 Subject: [PATCH] Don't blend kernel and frontend CLI args kernel args can be passed after `--`: ipython qtconsole -- --matplotlib inline ipython qtconsole --kernel julia -- --some-julia-flag --- diff --git a/IPython/consoleapp.py b/IPython/consoleapp.py index 2827527..bbcbce3 100644 --- a/IPython/consoleapp.py +++ b/IPython/consoleapp.py @@ -18,20 +18,13 @@ from IPython.config.application import boolean_flag from IPython.core.profiledir import ProfileDir from IPython.kernel.blocking import BlockingKernelClient from IPython.kernel import KernelManager -from IPython.kernel import tunnel_to_kernel, find_connection_file, swallow_argv +from IPython.kernel import tunnel_to_kernel, find_connection_file from IPython.kernel.kernelspec import NoSuchKernel from IPython.utils.path import filefind from IPython.utils.traitlets import ( Dict, List, Unicode, CUnicode, CBool, Any ) -from IPython.kernel.zmq.kernelapp import ( - kernel_flags, - kernel_aliases, - IPKernelApp -) -from IPython.kernel.zmq.pylab.config import InlineBackend from IPython.kernel.zmq.session import Session -from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell from IPython.kernel.connect import ConnectionFileMixin from IPython.utils.localinterfaces import localhost @@ -40,7 +33,7 @@ from IPython.utils.localinterfaces import localhost # Aliases and Flags #----------------------------------------------------------------------------- -flags = dict(kernel_flags) +flags = {} # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, @@ -60,7 +53,7 @@ app_flags.update(boolean_flag( )) flags.update(app_flags) -aliases = dict(kernel_aliases) +aliases = {} # also scrub aliases from the frontend app_aliases = dict( @@ -140,19 +133,12 @@ class IPythonConsoleApp(ConnectionFileMixin): to force a direct exit without any confirmation.""", ) - @property - def help_classes(self): - """ConsoleApps can configure kernels on the command-line + def build_kernel_argv(self, argv=None): + """build argv to be passed to kernel subprocess - But this shouldn't be written to a file + Override in subclasses if any args should be passed to the kernel """ - return self.classes + [IPKernelApp] + IPKernelApp.classes - - def build_kernel_argv(self, argv=None): - """build argv to be passed to kernel subprocess""" - if argv is None: - argv = sys.argv[1:] - self.kernel_argv = swallow_argv(argv, self.frontend_aliases, self.frontend_flags) + self.kernel_argv = self.extra_args def init_connection_file(self): """find the connection file, and load the info if found. diff --git a/IPython/terminal/ipapp.py b/IPython/terminal/ipapp.py index 8d70e8f..7477498 100755 --- a/IPython/terminal/ipapp.py +++ b/IPython/terminal/ipapp.py @@ -3,25 +3,10 @@ """ The :class:`~IPython.core.application.Application` object for the command line :command:`ipython` program. - -Authors -------- - -* Brian Granger -* Fernando Perez -* Min Ragan-Kelley """ -#----------------------------------------------------------------------------- -# Copyright (C) 2008-2011 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. from __future__ import absolute_import from __future__ import print_function diff --git a/jupyter_console/app.py b/jupyter_console/app.py index 3439873..e437fb4 100644 --- a/jupyter_console/app.py +++ b/jupyter_console/app.py @@ -2,17 +2,11 @@ This is not a complete console app, as subprocess will not be able to receive input, there is no real readline support, among other limitations. - -Authors: - -* Min RK -* Paul Ivanov - """ -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + import signal from IPython.terminal.ipapp import TerminalIPythonApp, frontend_flags as term_flags @@ -98,10 +92,12 @@ class ZMQTerminalIPythonApp(TerminalIPythonApp, IPythonConsoleApp): frontend_flags = Any(frontend_flags) subcommands = Dict() + + force_interact = True def parse_command_line(self, argv=None): super(ZMQTerminalIPythonApp, self).parse_command_line(argv) - self.build_kernel_argv(argv) + self.build_kernel_argv(self.extra_args) def init_shell(self): IPythonConsoleApp.initialize(self) diff --git a/jupyter_qtconsole/console/qtconsoleapp.py b/jupyter_qtconsole/console/qtconsoleapp.py index 56db9ae..83b57fe 100644 --- a/jupyter_qtconsole/console/qtconsoleapp.py +++ b/jupyter_qtconsole/console/qtconsoleapp.py @@ -5,13 +5,8 @@ input, there is no real readline support, among other limitations. """ # Copyright (c) IPython Development Team. -# Distributed under the terms of the Modified BSD License. +# Distributed under the terms of the Modified BSD License. -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- - -# stdlib imports import os import signal import sys @@ -46,10 +41,8 @@ if os.name == 'nt': sys.excepthook = gui_excepthook -# System library imports from IPython.external.qt import QtCore, QtGui -# Local imports from IPython.config.application import boolean_flag from IPython.config.application import catch_config_error from IPython.core.application import BaseIPythonApplication @@ -191,7 +184,7 @@ class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp): def parse_command_line(self, argv=None): super(IPythonQtConsoleApp, self).parse_command_line(argv) - self.build_kernel_argv(argv) + self.build_kernel_argv(self.extra_args) def new_frontend_master(self):