diff --git a/IPython/config/application.py b/IPython/config/application.py index d32a256..2fe90c0 100644 --- a/IPython/config/application.py +++ b/IPython/config/application.py @@ -145,6 +145,9 @@ class Application(SingletonConfigurable): # The version string of this application. version = Unicode(u'0.0') + + # the argv used to initialize the application + argv = List(Unicode) # The log level for the application log_level = Enum((0,10,20,30,40,50,'DEBUG','INFO','WARN','ERROR','CRITICAL'), @@ -457,6 +460,7 @@ class Application(SingletonConfigurable): def parse_command_line(self, argv=None): """Parse the command line arguments.""" argv = sys.argv[1:] if argv is None else argv + self.argv = list(argv) if argv and argv[0] == 'help': # turn `ipython help notebook` into `ipython notebook -h` diff --git a/IPython/core/application.py b/IPython/core/application.py index f2c0c22..cc1ff9d 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -53,6 +53,7 @@ from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, Set, Instan # aliases and flags base_aliases = { + 'profile-dir' : 'ProfileDir.location', 'profile' : 'BaseIPythonApplication.profile', 'ipython-dir' : 'BaseIPythonApplication.ipython_dir', 'log-level' : 'Application.log_level', diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index 08b4f58..efe5313 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -253,7 +253,7 @@ aliases.update({ aliases.pop('f', None) notebook_aliases = [u'port', u'port-retries', u'ip', u'keyfile', u'certfile', - u'notebook-dir'] + u'notebook-dir', u'profile', u'profile-dir'] #----------------------------------------------------------------------------- # NotebookApp @@ -471,17 +471,10 @@ class NotebookApp(BaseIPythonApplication): help=("Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded-For headers" "sent by the upstream reverse proxy. Neccesary if the proxy handles SSL") ) - + def parse_command_line(self, argv=None): super(NotebookApp, self).parse_command_line(argv) - if argv is None: - argv = sys.argv[1:] - - # Scrub frontend-specific flags - self.kernel_argv = swallow_argv(argv, notebook_aliases, notebook_flags) - # Kernel should inherit default config file from frontend - self.kernel_argv.append("--IPKernelApp.parent_appname='%s'" % self.name) - + if self.extra_args: f = os.path.abspath(self.extra_args[0]) if os.path.isdir(f): @@ -491,6 +484,15 @@ class NotebookApp(BaseIPythonApplication): nbdir = os.path.dirname(f) self.config.NotebookManager.notebook_dir = nbdir + def init_kernel_argv(self): + """construct the kernel arguments""" + # Scrub frontend-specific flags + self.kernel_argv = swallow_argv(self.argv, notebook_aliases, notebook_flags) + # Kernel should inherit default config file from frontend + self.kernel_argv.append("--IPKernelApp.parent_appname='%s'" % self.name) + # Kernel should get *absolute* path to profile directory + self.kernel_argv.extend(["--profile-dir", self.profile_dir.location]) + def init_configurables(self): # force Session default to be secure default_secure(self.config) @@ -657,6 +659,7 @@ class NotebookApp(BaseIPythonApplication): def initialize(self, argv=None): self.init_logging() super(NotebookApp, self).initialize(argv) + self.init_kernel_argv() self.init_configurables() self.init_components() self.init_webapp() diff --git a/IPython/parallel/apps/baseapp.py b/IPython/parallel/apps/baseapp.py index 2f2033a..62346cd 100644 --- a/IPython/parallel/apps/baseapp.py +++ b/IPython/parallel/apps/baseapp.py @@ -71,7 +71,6 @@ class ParallelCrashHandler(CrashHandler): base_aliases = {} base_aliases.update(base_ip_aliases) base_aliases.update({ - 'profile-dir' : 'ProfileDir.location', 'work-dir' : 'BaseParallelApplication.work_dir', 'log-to-file' : 'BaseParallelApplication.log_to_file', 'clean-logs' : 'BaseParallelApplication.clean_logs',