##// END OF EJS Templates
Merge pull request #964 from takluyver/default-profile...
Min RK -
r5265:c3d885fa merge
parent child Browse files
Show More
@@ -104,11 +104,9 b' class BaseIPythonApplication(Application):'
104 def _config_file_paths_default(self):
104 def _config_file_paths_default(self):
105 return [os.getcwdu()]
105 return [os.getcwdu()]
106
106
107 profile = Unicode(u'', config=True,
107 profile = Unicode(u'default', config=True,
108 help="""The IPython profile to use."""
108 help="""The IPython profile to use."""
109 )
109 )
110 def _profile_default(self):
111 return "python3" if py3compat.PY3 else "default"
112
110
113 def _profile_changed(self, name, old, new):
111 def _profile_changed(self, name, old, new):
114 self.builtin_profile_dir = os.path.join(
112 self.builtin_profile_dir = os.path.join(
@@ -230,7 +228,7 b' class BaseIPythonApplication(Application):'
230 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
228 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
231 except ProfileDirError:
229 except ProfileDirError:
232 # not found, maybe create it (always create default profile)
230 # not found, maybe create it (always create default profile)
233 if self.auto_create or self.profile==self._profile_default():
231 if self.auto_create or self.profile=='default':
234 try:
232 try:
235 p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
233 p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
236 except ProfileDirError:
234 except ProfileDirError:
@@ -527,7 +527,11 b' Currently the magic system has the following functions:\\n"""'
527
527
528 def magic_profile(self, parameter_s=''):
528 def magic_profile(self, parameter_s=''):
529 """Print your currently active IPython profile."""
529 """Print your currently active IPython profile."""
530 print self.shell.profile
530 from IPython.core.application import BaseIPythonApplication
531 if BaseIPythonApplication.initialized():
532 print BaseIPythonApplication.instance().profile
533 else:
534 error("profile is an application-level value, but you don't appear to be in an IPython application")
531
535
532 def magic_pinfo(self, parameter_s='', namespaces=None):
536 def magic_pinfo(self, parameter_s='', namespaces=None):
533 """Provide detailed information about an object.
537 """Provide detailed information about an object.
@@ -80,7 +80,7 b' def test_startup_py():'
80 # write simple test file, to check that the startup file was run
80 # write simple test file, to check that the startup file was run
81 fname = os.path.join(TMP_TEST_DIR, 'test.py')
81 fname = os.path.join(TMP_TEST_DIR, 'test.py')
82 with open(fname, 'w') as f:
82 with open(fname, 'w') as f:
83 f.write('print zzz\n')
83 f.write(py3compat.doctest_refactor_print('print zzz\n'))
84 # validate output
84 # validate output
85 tt.ipexec_validate(fname, '123', '',
85 tt.ipexec_validate(fname, '123', '',
86 options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
86 options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
@@ -100,4 +100,4 b' def test_startup_ipy():'
100 tt.ipexec_validate(fname, 'test', '',
100 tt.ipexec_validate(fname, 'test', '',
101 options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
101 options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
102
102
103 No newline at end of file
103
@@ -64,6 +64,7 b' class Kernel(Configurable):'
64
64
65 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
65 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
66 session = Instance(Session)
66 session = Instance(Session)
67 profile_dir = Instance('IPython.core.profiledir.ProfileDir')
67 shell_socket = Instance('zmq.Socket')
68 shell_socket = Instance('zmq.Socket')
68 iopub_socket = Instance('zmq.Socket')
69 iopub_socket = Instance('zmq.Socket')
69 stdin_socket = Instance('zmq.Socket')
70 stdin_socket = Instance('zmq.Socket')
@@ -106,7 +107,9 b' class Kernel(Configurable):'
106 atexit.register(self._at_shutdown)
107 atexit.register(self._at_shutdown)
107
108
108 # Initialize the InteractiveShell subclass
109 # Initialize the InteractiveShell subclass
109 self.shell = ZMQInteractiveShell.instance(config=self.config)
110 self.shell = ZMQInteractiveShell.instance(config=self.config,
111 profile_dir = self.profile_dir,
112 )
110 self.shell.displayhook.session = self.session
113 self.shell.displayhook.session = self.session
111 self.shell.displayhook.pub_socket = self.iopub_socket
114 self.shell.displayhook.pub_socket = self.iopub_socket
112 self.shell.display_pub.session = self.session
115 self.shell.display_pub.session = self.session
@@ -739,16 +742,16 b' class IPKernelApp(KernelApp, InteractiveShellApp):'
739 self.init_code()
742 self.init_code()
740
743
741 def init_kernel(self):
744 def init_kernel(self):
742 kernel_factory = Kernel
743
745
744 if self.pylab:
746 if self.pylab:
745 gui, backend = pylabtools.find_gui_and_backend(self.pylab)
747 gui, backend = pylabtools.find_gui_and_backend(self.pylab)
746
748
747 kernel = kernel_factory(config=self.config, session=self.session,
749 kernel = Kernel(config=self.config, session=self.session,
748 shell_socket=self.shell_socket,
750 shell_socket=self.shell_socket,
749 iopub_socket=self.iopub_socket,
751 iopub_socket=self.iopub_socket,
750 stdin_socket=self.stdin_socket,
752 stdin_socket=self.stdin_socket,
751 log=self.log,
753 log=self.log,
754 profile_dir=self.profile_dir,
752 )
755 )
753 self.kernel = kernel
756 self.kernel = kernel
754 kernel.record_ports(self.ports)
757 kernel.record_ports(self.ports)
General Comments 0
You need to be logged in to leave comments. Login now