##// END OF EJS Templates
Merge pull request #6961 from minrk/profile-dir-no-3p...
Thomas Kluyver -
r18965:85b118a7 merge
parent child Browse files
Show More
@@ -291,7 +291,11 b' class IPythonConsoleApp(ConnectionFileMixin):'
291 self.exit(1)
291 self.exit(1)
292
292
293 self.kernel_manager.client_factory = self.kernel_client_class
293 self.kernel_manager.client_factory = self.kernel_client_class
294 self.kernel_manager.start_kernel(extra_arguments=self.kernel_argv)
294 # FIXME: remove special treatment of IPython kernels
295 kwargs = {}
296 if self.kernel_manager.ipython_kernel:
297 kwargs['extra_arguments'] = self.kernel_argv
298 self.kernel_manager.start_kernel(**kwargs)
295 atexit.register(self.kernel_manager.cleanup_ipc_files)
299 atexit.register(self.kernel_manager.cleanup_ipc_files)
296
300
297 if self.sshserver:
301 if self.sshserver:
@@ -324,7 +324,7 b' class NotebookApp(BaseIPythonApplication):'
324 list=(NbserverListApp, NbserverListApp.description.splitlines()[0]),
324 list=(NbserverListApp, NbserverListApp.description.splitlines()[0]),
325 )
325 )
326
326
327 kernel_argv = List(Unicode)
327 ipython_kernel_argv = List(Unicode)
328
328
329 _log_formatter_cls = LogFormatter
329 _log_formatter_cls = LogFormatter
330
330
@@ -683,16 +683,17 b' class NotebookApp(BaseIPythonApplication):'
683 self.update_config(c)
683 self.update_config(c)
684
684
685 def init_kernel_argv(self):
685 def init_kernel_argv(self):
686 """construct the kernel arguments"""
686 """add the profile-dir to arguments to be passed to IPython kernels"""
687 # FIXME: remove special treatment of IPython kernels
687 # Kernel should get *absolute* path to profile directory
688 # Kernel should get *absolute* path to profile directory
688 self.kernel_argv = ["--profile-dir", self.profile_dir.location]
689 self.ipython_kernel_argv = ["--profile-dir", self.profile_dir.location]
689
690
690 def init_configurables(self):
691 def init_configurables(self):
691 # force Session default to be secure
692 # force Session default to be secure
692 default_secure(self.config)
693 default_secure(self.config)
693 kls = import_item(self.kernel_manager_class)
694 kls = import_item(self.kernel_manager_class)
694 self.kernel_manager = kls(
695 self.kernel_manager = kls(
695 parent=self, log=self.log, kernel_argv=self.kernel_argv,
696 parent=self, log=self.log, ipython_kernel_argv=self.ipython_kernel_argv,
696 connection_dir = self.profile_dir.security_dir,
697 connection_dir = self.profile_dir.security_dir,
697 )
698 )
698 kls = import_item(self.contents_manager_class)
699 kls = import_item(self.contents_manager_class)
@@ -1,35 +1,22 b''
1 """A kernel manager relating notebooks and kernels
1 """A MultiKernelManager for use in the notebook webserver
2
2
3 Authors:
3 - raises HTTPErrors
4
4 - creates REST API models
5 * Brian Granger
6 """
5 """
7
6
8 #-----------------------------------------------------------------------------
7 # Copyright (c) IPython Development Team.
9 # Copyright (C) 2013 The IPython Development Team
8 # Distributed under the terms of the Modified BSD License.
10 #
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
13 #-----------------------------------------------------------------------------
14
15 #-----------------------------------------------------------------------------
16 # Imports
17 #-----------------------------------------------------------------------------
18
9
19 import os
10 import os
20
11
21 from tornado import web
12 from tornado import web
22
13
23 from IPython.kernel.multikernelmanager import MultiKernelManager
14 from IPython.kernel.multikernelmanager import MultiKernelManager
24 from IPython.utils.traitlets import List, Unicode, TraitError
15 from IPython.utils.traitlets import Unicode, TraitError
25
16
26 from IPython.html.utils import to_os_path
17 from IPython.html.utils import to_os_path
27 from IPython.utils.py3compat import getcwd
18 from IPython.utils.py3compat import getcwd
28
19
29 #-----------------------------------------------------------------------------
30 # Classes
31 #-----------------------------------------------------------------------------
32
33
20
34 class MappingKernelManager(MultiKernelManager):
21 class MappingKernelManager(MultiKernelManager):
35 """A KernelManager that handles notebook mapping and HTTP error handling"""
22 """A KernelManager that handles notebook mapping and HTTP error handling"""
@@ -37,8 +24,6 b' class MappingKernelManager(MultiKernelManager):'
37 def _kernel_manager_class_default(self):
24 def _kernel_manager_class_default(self):
38 return "IPython.kernel.ioloop.IOLoopKernelManager"
25 return "IPython.kernel.ioloop.IOLoopKernelManager"
39
26
40 kernel_argv = List(Unicode)
41
42 root_dir = Unicode(getcwd(), config=True)
27 root_dir = Unicode(getcwd(), config=True)
43
28
44 def _root_dir_changed(self, name, old, new):
29 def _root_dir_changed(self, name, old, new):
@@ -89,7 +74,6 b' class MappingKernelManager(MultiKernelManager):'
89 an existing kernel is returned, but it may be checked in the future.
74 an existing kernel is returned, but it may be checked in the future.
90 """
75 """
91 if kernel_id is None:
76 if kernel_id is None:
92 kwargs['extra_arguments'] = self.kernel_argv
93 if path is not None:
77 if path is not None:
94 kwargs['cwd'] = self.cwd_for_path(path)
78 kwargs['cwd'] = self.cwd_for_path(path)
95 kernel_id = super(MappingKernelManager, self).start_kernel(
79 kernel_id = super(MappingKernelManager, self).start_kernel(
@@ -13,7 +13,7 b' import zmq'
13 from IPython.config.configurable import LoggingConfigurable
13 from IPython.config.configurable import LoggingConfigurable
14 from IPython.utils.importstring import import_item
14 from IPython.utils.importstring import import_item
15 from IPython.utils.traitlets import (
15 from IPython.utils.traitlets import (
16 Instance, Dict, Unicode, Any, DottedObjectName
16 Instance, Dict, List, Unicode, Any, DottedObjectName
17 )
17 )
18 from IPython.utils.py3compat import unicode_type
18 from IPython.utils.py3compat import unicode_type
19
19
@@ -42,6 +42,8 b' def kernel_method(f):'
42 class MultiKernelManager(LoggingConfigurable):
42 class MultiKernelManager(LoggingConfigurable):
43 """A class for managing multiple kernels."""
43 """A class for managing multiple kernels."""
44
44
45 ipython_kernel_argv = List(Unicode)
46
45 default_kernel_name = Unicode(NATIVE_KERNEL_NAME, config=True,
47 default_kernel_name = Unicode(NATIVE_KERNEL_NAME, config=True,
46 help="The name of the default kernel to start"
48 help="The name of the default kernel to start"
47 )
49 )
@@ -104,6 +106,9 b' class MultiKernelManager(LoggingConfigurable):'
104 self.connection_dir, "kernel-%s.json" % kernel_id),
106 self.connection_dir, "kernel-%s.json" % kernel_id),
105 parent=self, autorestart=True, log=self.log, kernel_name=kernel_name,
107 parent=self, autorestart=True, log=self.log, kernel_name=kernel_name,
106 )
108 )
109 # FIXME: remove special treatment of IPython kernels
110 if km.ipython_kernel:
111 kwargs.setdefault('extra_arguments', self.ipython_kernel_argv)
107 km.start_kernel(**kwargs)
112 km.start_kernel(**kwargs)
108 self._kernels[kernel_id] = km
113 self._kernels[kernel_id] = km
109 return kernel_id
114 return kernel_id
@@ -193,8 +193,10 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):'
193 autorestart=True,
193 autorestart=True,
194 )
194 )
195 # start the kernel
195 # start the kernel
196 kwargs = dict()
196 kwargs = {}
197 kwargs['extra_arguments'] = self.kernel_argv
197 # FIXME: remove special treatment of IPython kernels
198 if self.kernel_manager.ipython_kernel:
199 kwargs['extra_arguments'] = self.kernel_argv
198 kernel_manager.start_kernel(**kwargs)
200 kernel_manager.start_kernel(**kwargs)
199 kernel_manager.client_factory = self.kernel_client_class
201 kernel_manager.client_factory = self.kernel_client_class
200 kernel_client = kernel_manager.client()
202 kernel_client = kernel_manager.client()
General Comments 0
You need to be logged in to leave comments. Login now