##// END OF EJS Templates
Merge pull request #4014 from sixpi/fix_matploltib_typo...
Thomas Kluyver -
r12155:25911fa8 merge
parent child Browse files
Show More
@@ -1,386 +1,386 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # encoding: utf-8
2 # encoding: utf-8
3 """
3 """
4 The :class:`~IPython.core.application.Application` object for the command
4 The :class:`~IPython.core.application.Application` object for the command
5 line :command:`ipython` program.
5 line :command:`ipython` program.
6
6
7 Authors
7 Authors
8 -------
8 -------
9
9
10 * Brian Granger
10 * Brian Granger
11 * Fernando Perez
11 * Fernando Perez
12 * Min Ragan-Kelley
12 * Min Ragan-Kelley
13 """
13 """
14
14
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16 # Copyright (C) 2008-2011 The IPython Development Team
16 # Copyright (C) 2008-2011 The IPython Development Team
17 #
17 #
18 # Distributed under the terms of the BSD License. The full license is in
18 # Distributed under the terms of the BSD License. The full license is in
19 # the file COPYING, distributed as part of this software.
19 # the file COPYING, distributed as part of this software.
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21
21
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 # Imports
23 # Imports
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25
25
26 from __future__ import absolute_import
26 from __future__ import absolute_import
27
27
28 import logging
28 import logging
29 import os
29 import os
30 import sys
30 import sys
31
31
32 from IPython.config.loader import (
32 from IPython.config.loader import (
33 Config, PyFileConfigLoader, ConfigFileNotFound
33 Config, PyFileConfigLoader, ConfigFileNotFound
34 )
34 )
35 from IPython.config.application import boolean_flag, catch_config_error
35 from IPython.config.application import boolean_flag, catch_config_error
36 from IPython.core import release
36 from IPython.core import release
37 from IPython.core import usage
37 from IPython.core import usage
38 from IPython.core.completer import IPCompleter
38 from IPython.core.completer import IPCompleter
39 from IPython.core.crashhandler import CrashHandler
39 from IPython.core.crashhandler import CrashHandler
40 from IPython.core.formatters import PlainTextFormatter
40 from IPython.core.formatters import PlainTextFormatter
41 from IPython.core.history import HistoryManager
41 from IPython.core.history import HistoryManager
42 from IPython.core.prompts import PromptManager
42 from IPython.core.prompts import PromptManager
43 from IPython.core.application import (
43 from IPython.core.application import (
44 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
44 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
45 )
45 )
46 from IPython.core.magics import ScriptMagics
46 from IPython.core.magics import ScriptMagics
47 from IPython.core.shellapp import (
47 from IPython.core.shellapp import (
48 InteractiveShellApp, shell_flags, shell_aliases
48 InteractiveShellApp, shell_flags, shell_aliases
49 )
49 )
50 from IPython.terminal.interactiveshell import TerminalInteractiveShell
50 from IPython.terminal.interactiveshell import TerminalInteractiveShell
51 from IPython.utils import warn
51 from IPython.utils import warn
52 from IPython.utils.path import get_ipython_dir, check_for_old_config
52 from IPython.utils.path import get_ipython_dir, check_for_old_config
53 from IPython.utils.traitlets import (
53 from IPython.utils.traitlets import (
54 Bool, List, Dict,
54 Bool, List, Dict,
55 )
55 )
56
56
57 #-----------------------------------------------------------------------------
57 #-----------------------------------------------------------------------------
58 # Globals, utilities and helpers
58 # Globals, utilities and helpers
59 #-----------------------------------------------------------------------------
59 #-----------------------------------------------------------------------------
60
60
61 _examples = """
61 _examples = """
62 ipython --matplotlib # enable matplotlib integration
62 ipython --matplotlib # enable matplotlib integration
63 ipython --matploltib=qt # enable matplotlib integration with qt4 backend
63 ipython --matplotlib=qt # enable matplotlib integration with qt4 backend
64
64
65 ipython --log-level=DEBUG # set logging to DEBUG
65 ipython --log-level=DEBUG # set logging to DEBUG
66 ipython --profile=foo # start with profile foo
66 ipython --profile=foo # start with profile foo
67
67
68 ipython qtconsole # start the qtconsole GUI application
68 ipython qtconsole # start the qtconsole GUI application
69 ipython help qtconsole # show the help for the qtconsole subcmd
69 ipython help qtconsole # show the help for the qtconsole subcmd
70
70
71 ipython console # start the terminal-based console application
71 ipython console # start the terminal-based console application
72 ipython help console # show the help for the console subcmd
72 ipython help console # show the help for the console subcmd
73
73
74 ipython notebook # start the IPython notebook
74 ipython notebook # start the IPython notebook
75 ipython help notebook # show the help for the notebook subcmd
75 ipython help notebook # show the help for the notebook subcmd
76
76
77 ipython profile create foo # create profile foo w/ default config files
77 ipython profile create foo # create profile foo w/ default config files
78 ipython help profile # show the help for the profile subcmd
78 ipython help profile # show the help for the profile subcmd
79
79
80 ipython locate # print the path to the IPython directory
80 ipython locate # print the path to the IPython directory
81 ipython locate profile foo # print the path to the directory for profile `foo`
81 ipython locate profile foo # print the path to the directory for profile `foo`
82
82
83 ipython nbconvert # convert notebooks to/from other formats
83 ipython nbconvert # convert notebooks to/from other formats
84 """
84 """
85
85
86 #-----------------------------------------------------------------------------
86 #-----------------------------------------------------------------------------
87 # Crash handler for this application
87 # Crash handler for this application
88 #-----------------------------------------------------------------------------
88 #-----------------------------------------------------------------------------
89
89
90 class IPAppCrashHandler(CrashHandler):
90 class IPAppCrashHandler(CrashHandler):
91 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
91 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
92
92
93 def __init__(self, app):
93 def __init__(self, app):
94 contact_name = release.author
94 contact_name = release.author
95 contact_email = release.author_email
95 contact_email = release.author_email
96 bug_tracker = 'https://github.com/ipython/ipython/issues'
96 bug_tracker = 'https://github.com/ipython/ipython/issues'
97 super(IPAppCrashHandler,self).__init__(
97 super(IPAppCrashHandler,self).__init__(
98 app, contact_name, contact_email, bug_tracker
98 app, contact_name, contact_email, bug_tracker
99 )
99 )
100
100
101 def make_report(self,traceback):
101 def make_report(self,traceback):
102 """Return a string containing a crash report."""
102 """Return a string containing a crash report."""
103
103
104 sec_sep = self.section_sep
104 sec_sep = self.section_sep
105 # Start with parent report
105 # Start with parent report
106 report = [super(IPAppCrashHandler, self).make_report(traceback)]
106 report = [super(IPAppCrashHandler, self).make_report(traceback)]
107 # Add interactive-specific info we may have
107 # Add interactive-specific info we may have
108 rpt_add = report.append
108 rpt_add = report.append
109 try:
109 try:
110 rpt_add(sec_sep+"History of session input:")
110 rpt_add(sec_sep+"History of session input:")
111 for line in self.app.shell.user_ns['_ih']:
111 for line in self.app.shell.user_ns['_ih']:
112 rpt_add(line)
112 rpt_add(line)
113 rpt_add('\n*** Last line of input (may not be in above history):\n')
113 rpt_add('\n*** Last line of input (may not be in above history):\n')
114 rpt_add(self.app.shell._last_input_line+'\n')
114 rpt_add(self.app.shell._last_input_line+'\n')
115 except:
115 except:
116 pass
116 pass
117
117
118 return ''.join(report)
118 return ''.join(report)
119
119
120 #-----------------------------------------------------------------------------
120 #-----------------------------------------------------------------------------
121 # Aliases and Flags
121 # Aliases and Flags
122 #-----------------------------------------------------------------------------
122 #-----------------------------------------------------------------------------
123 flags = dict(base_flags)
123 flags = dict(base_flags)
124 flags.update(shell_flags)
124 flags.update(shell_flags)
125 frontend_flags = {}
125 frontend_flags = {}
126 addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
126 addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
127 addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
127 addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
128 'Turn on auto editing of files with syntax errors.',
128 'Turn on auto editing of files with syntax errors.',
129 'Turn off auto editing of files with syntax errors.'
129 'Turn off auto editing of files with syntax errors.'
130 )
130 )
131 addflag('banner', 'TerminalIPythonApp.display_banner',
131 addflag('banner', 'TerminalIPythonApp.display_banner',
132 "Display a banner upon starting IPython.",
132 "Display a banner upon starting IPython.",
133 "Don't display a banner upon starting IPython."
133 "Don't display a banner upon starting IPython."
134 )
134 )
135 addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
135 addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
136 """Set to confirm when you try to exit IPython with an EOF (Control-D
136 """Set to confirm when you try to exit IPython with an EOF (Control-D
137 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
137 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
138 you can force a direct exit without any confirmation.""",
138 you can force a direct exit without any confirmation.""",
139 "Don't prompt the user when exiting."
139 "Don't prompt the user when exiting."
140 )
140 )
141 addflag('term-title', 'TerminalInteractiveShell.term_title',
141 addflag('term-title', 'TerminalInteractiveShell.term_title',
142 "Enable auto setting the terminal title.",
142 "Enable auto setting the terminal title.",
143 "Disable auto setting the terminal title."
143 "Disable auto setting the terminal title."
144 )
144 )
145 classic_config = Config()
145 classic_config = Config()
146 classic_config.InteractiveShell.cache_size = 0
146 classic_config.InteractiveShell.cache_size = 0
147 classic_config.PlainTextFormatter.pprint = False
147 classic_config.PlainTextFormatter.pprint = False
148 classic_config.PromptManager.in_template = '>>> '
148 classic_config.PromptManager.in_template = '>>> '
149 classic_config.PromptManager.in2_template = '... '
149 classic_config.PromptManager.in2_template = '... '
150 classic_config.PromptManager.out_template = ''
150 classic_config.PromptManager.out_template = ''
151 classic_config.InteractiveShell.separate_in = ''
151 classic_config.InteractiveShell.separate_in = ''
152 classic_config.InteractiveShell.separate_out = ''
152 classic_config.InteractiveShell.separate_out = ''
153 classic_config.InteractiveShell.separate_out2 = ''
153 classic_config.InteractiveShell.separate_out2 = ''
154 classic_config.InteractiveShell.colors = 'NoColor'
154 classic_config.InteractiveShell.colors = 'NoColor'
155 classic_config.InteractiveShell.xmode = 'Plain'
155 classic_config.InteractiveShell.xmode = 'Plain'
156
156
157 frontend_flags['classic']=(
157 frontend_flags['classic']=(
158 classic_config,
158 classic_config,
159 "Gives IPython a similar feel to the classic Python prompt."
159 "Gives IPython a similar feel to the classic Python prompt."
160 )
160 )
161 # # log doesn't make so much sense this way anymore
161 # # log doesn't make so much sense this way anymore
162 # paa('--log','-l',
162 # paa('--log','-l',
163 # action='store_true', dest='InteractiveShell.logstart',
163 # action='store_true', dest='InteractiveShell.logstart',
164 # help="Start logging to the default log file (./ipython_log.py).")
164 # help="Start logging to the default log file (./ipython_log.py).")
165 #
165 #
166 # # quick is harder to implement
166 # # quick is harder to implement
167 frontend_flags['quick']=(
167 frontend_flags['quick']=(
168 {'TerminalIPythonApp' : {'quick' : True}},
168 {'TerminalIPythonApp' : {'quick' : True}},
169 "Enable quick startup with no config files."
169 "Enable quick startup with no config files."
170 )
170 )
171
171
172 frontend_flags['i'] = (
172 frontend_flags['i'] = (
173 {'TerminalIPythonApp' : {'force_interact' : True}},
173 {'TerminalIPythonApp' : {'force_interact' : True}},
174 """If running code from the command line, become interactive afterwards.
174 """If running code from the command line, become interactive afterwards.
175 Note: can also be given simply as '-i.'"""
175 Note: can also be given simply as '-i.'"""
176 )
176 )
177 flags.update(frontend_flags)
177 flags.update(frontend_flags)
178
178
179 aliases = dict(base_aliases)
179 aliases = dict(base_aliases)
180 aliases.update(shell_aliases)
180 aliases.update(shell_aliases)
181
181
182 #-----------------------------------------------------------------------------
182 #-----------------------------------------------------------------------------
183 # Main classes and functions
183 # Main classes and functions
184 #-----------------------------------------------------------------------------
184 #-----------------------------------------------------------------------------
185
185
186
186
187 class LocateIPythonApp(BaseIPythonApplication):
187 class LocateIPythonApp(BaseIPythonApplication):
188 description = """print the path to the IPython dir"""
188 description = """print the path to the IPython dir"""
189 subcommands = Dict(dict(
189 subcommands = Dict(dict(
190 profile=('IPython.core.profileapp.ProfileLocate',
190 profile=('IPython.core.profileapp.ProfileLocate',
191 "print the path to an IPython profile directory",
191 "print the path to an IPython profile directory",
192 ),
192 ),
193 ))
193 ))
194 def start(self):
194 def start(self):
195 if self.subapp is not None:
195 if self.subapp is not None:
196 return self.subapp.start()
196 return self.subapp.start()
197 else:
197 else:
198 print self.ipython_dir
198 print self.ipython_dir
199
199
200
200
201 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
201 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
202 name = u'ipython'
202 name = u'ipython'
203 description = usage.cl_usage
203 description = usage.cl_usage
204 crash_handler_class = IPAppCrashHandler
204 crash_handler_class = IPAppCrashHandler
205 examples = _examples
205 examples = _examples
206
206
207 flags = Dict(flags)
207 flags = Dict(flags)
208 aliases = Dict(aliases)
208 aliases = Dict(aliases)
209 classes = List()
209 classes = List()
210 def _classes_default(self):
210 def _classes_default(self):
211 """This has to be in a method, for TerminalIPythonApp to be available."""
211 """This has to be in a method, for TerminalIPythonApp to be available."""
212 return [
212 return [
213 InteractiveShellApp, # ShellApp comes before TerminalApp, because
213 InteractiveShellApp, # ShellApp comes before TerminalApp, because
214 self.__class__, # it will also affect subclasses (e.g. QtConsole)
214 self.__class__, # it will also affect subclasses (e.g. QtConsole)
215 TerminalInteractiveShell,
215 TerminalInteractiveShell,
216 PromptManager,
216 PromptManager,
217 HistoryManager,
217 HistoryManager,
218 ProfileDir,
218 ProfileDir,
219 PlainTextFormatter,
219 PlainTextFormatter,
220 IPCompleter,
220 IPCompleter,
221 ScriptMagics,
221 ScriptMagics,
222 ]
222 ]
223
223
224 subcommands = Dict(dict(
224 subcommands = Dict(dict(
225 qtconsole=('IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',
225 qtconsole=('IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',
226 """Launch the IPython Qt Console."""
226 """Launch the IPython Qt Console."""
227 ),
227 ),
228 notebook=('IPython.html.notebookapp.NotebookApp',
228 notebook=('IPython.html.notebookapp.NotebookApp',
229 """Launch the IPython HTML Notebook Server."""
229 """Launch the IPython HTML Notebook Server."""
230 ),
230 ),
231 profile = ("IPython.core.profileapp.ProfileApp",
231 profile = ("IPython.core.profileapp.ProfileApp",
232 "Create and manage IPython profiles."
232 "Create and manage IPython profiles."
233 ),
233 ),
234 kernel = ("IPython.kernel.zmq.kernelapp.IPKernelApp",
234 kernel = ("IPython.kernel.zmq.kernelapp.IPKernelApp",
235 "Start a kernel without an attached frontend."
235 "Start a kernel without an attached frontend."
236 ),
236 ),
237 console=('IPython.terminal.console.app.ZMQTerminalIPythonApp',
237 console=('IPython.terminal.console.app.ZMQTerminalIPythonApp',
238 """Launch the IPython terminal-based Console."""
238 """Launch the IPython terminal-based Console."""
239 ),
239 ),
240 locate=('IPython.terminal.ipapp.LocateIPythonApp',
240 locate=('IPython.terminal.ipapp.LocateIPythonApp',
241 LocateIPythonApp.description
241 LocateIPythonApp.description
242 ),
242 ),
243 history=('IPython.core.historyapp.HistoryApp',
243 history=('IPython.core.historyapp.HistoryApp',
244 "Manage the IPython history database."
244 "Manage the IPython history database."
245 ),
245 ),
246 nbconvert=('IPython.nbconvert.nbconvertapp.NbConvertApp',
246 nbconvert=('IPython.nbconvert.nbconvertapp.NbConvertApp',
247 "Convert notebooks to/from other formats."
247 "Convert notebooks to/from other formats."
248 ),
248 ),
249 ))
249 ))
250
250
251 # *do* autocreate requested profile, but don't create the config file.
251 # *do* autocreate requested profile, but don't create the config file.
252 auto_create=Bool(True)
252 auto_create=Bool(True)
253 # configurables
253 # configurables
254 ignore_old_config=Bool(False, config=True,
254 ignore_old_config=Bool(False, config=True,
255 help="Suppress warning messages about legacy config files"
255 help="Suppress warning messages about legacy config files"
256 )
256 )
257 quick = Bool(False, config=True,
257 quick = Bool(False, config=True,
258 help="""Start IPython quickly by skipping the loading of config files."""
258 help="""Start IPython quickly by skipping the loading of config files."""
259 )
259 )
260 def _quick_changed(self, name, old, new):
260 def _quick_changed(self, name, old, new):
261 if new:
261 if new:
262 self.load_config_file = lambda *a, **kw: None
262 self.load_config_file = lambda *a, **kw: None
263 self.ignore_old_config=True
263 self.ignore_old_config=True
264
264
265 display_banner = Bool(True, config=True,
265 display_banner = Bool(True, config=True,
266 help="Whether to display a banner upon starting IPython."
266 help="Whether to display a banner upon starting IPython."
267 )
267 )
268
268
269 # if there is code of files to run from the cmd line, don't interact
269 # if there is code of files to run from the cmd line, don't interact
270 # unless the --i flag (App.force_interact) is true.
270 # unless the --i flag (App.force_interact) is true.
271 force_interact = Bool(False, config=True,
271 force_interact = Bool(False, config=True,
272 help="""If a command or file is given via the command-line,
272 help="""If a command or file is given via the command-line,
273 e.g. 'ipython foo.py"""
273 e.g. 'ipython foo.py"""
274 )
274 )
275 def _force_interact_changed(self, name, old, new):
275 def _force_interact_changed(self, name, old, new):
276 if new:
276 if new:
277 self.interact = True
277 self.interact = True
278
278
279 def _file_to_run_changed(self, name, old, new):
279 def _file_to_run_changed(self, name, old, new):
280 if new:
280 if new:
281 self.something_to_run = True
281 self.something_to_run = True
282 if new and not self.force_interact:
282 if new and not self.force_interact:
283 self.interact = False
283 self.interact = False
284 _code_to_run_changed = _file_to_run_changed
284 _code_to_run_changed = _file_to_run_changed
285 _module_to_run_changed = _file_to_run_changed
285 _module_to_run_changed = _file_to_run_changed
286
286
287 # internal, not-configurable
287 # internal, not-configurable
288 interact=Bool(True)
288 interact=Bool(True)
289 something_to_run=Bool(False)
289 something_to_run=Bool(False)
290
290
291 def parse_command_line(self, argv=None):
291 def parse_command_line(self, argv=None):
292 """override to allow old '-pylab' flag with deprecation warning"""
292 """override to allow old '-pylab' flag with deprecation warning"""
293
293
294 argv = sys.argv[1:] if argv is None else argv
294 argv = sys.argv[1:] if argv is None else argv
295
295
296 if '-pylab' in argv:
296 if '-pylab' in argv:
297 # deprecated `-pylab` given,
297 # deprecated `-pylab` given,
298 # warn and transform into current syntax
298 # warn and transform into current syntax
299 argv = argv[:] # copy, don't clobber
299 argv = argv[:] # copy, don't clobber
300 idx = argv.index('-pylab')
300 idx = argv.index('-pylab')
301 warn.warn("`-pylab` flag has been deprecated.\n"
301 warn.warn("`-pylab` flag has been deprecated.\n"
302 " Use `--matplotlib <backend>` and import pylab manually.")
302 " Use `--matplotlib <backend>` and import pylab manually.")
303 argv[idx] = '--pylab'
303 argv[idx] = '--pylab'
304
304
305 return super(TerminalIPythonApp, self).parse_command_line(argv)
305 return super(TerminalIPythonApp, self).parse_command_line(argv)
306
306
307 @catch_config_error
307 @catch_config_error
308 def initialize(self, argv=None):
308 def initialize(self, argv=None):
309 """Do actions after construct, but before starting the app."""
309 """Do actions after construct, but before starting the app."""
310 super(TerminalIPythonApp, self).initialize(argv)
310 super(TerminalIPythonApp, self).initialize(argv)
311 if self.subapp is not None:
311 if self.subapp is not None:
312 # don't bother initializing further, starting subapp
312 # don't bother initializing further, starting subapp
313 return
313 return
314 if not self.ignore_old_config:
314 if not self.ignore_old_config:
315 check_for_old_config(self.ipython_dir)
315 check_for_old_config(self.ipython_dir)
316 # print self.extra_args
316 # print self.extra_args
317 if self.extra_args and not self.something_to_run:
317 if self.extra_args and not self.something_to_run:
318 self.file_to_run = self.extra_args[0]
318 self.file_to_run = self.extra_args[0]
319 self.init_path()
319 self.init_path()
320 # create the shell
320 # create the shell
321 self.init_shell()
321 self.init_shell()
322 # and draw the banner
322 # and draw the banner
323 self.init_banner()
323 self.init_banner()
324 # Now a variety of things that happen after the banner is printed.
324 # Now a variety of things that happen after the banner is printed.
325 self.init_gui_pylab()
325 self.init_gui_pylab()
326 self.init_extensions()
326 self.init_extensions()
327 self.init_code()
327 self.init_code()
328
328
329 def init_shell(self):
329 def init_shell(self):
330 """initialize the InteractiveShell instance"""
330 """initialize the InteractiveShell instance"""
331 # Create an InteractiveShell instance.
331 # Create an InteractiveShell instance.
332 # shell.display_banner should always be False for the terminal
332 # shell.display_banner should always be False for the terminal
333 # based app, because we call shell.show_banner() by hand below
333 # based app, because we call shell.show_banner() by hand below
334 # so the banner shows *before* all extension loading stuff.
334 # so the banner shows *before* all extension loading stuff.
335 self.shell = TerminalInteractiveShell.instance(parent=self,
335 self.shell = TerminalInteractiveShell.instance(parent=self,
336 display_banner=False, profile_dir=self.profile_dir,
336 display_banner=False, profile_dir=self.profile_dir,
337 ipython_dir=self.ipython_dir)
337 ipython_dir=self.ipython_dir)
338 self.shell.configurables.append(self)
338 self.shell.configurables.append(self)
339
339
340 def init_banner(self):
340 def init_banner(self):
341 """optionally display the banner"""
341 """optionally display the banner"""
342 if self.display_banner and self.interact:
342 if self.display_banner and self.interact:
343 self.shell.show_banner()
343 self.shell.show_banner()
344 # Make sure there is a space below the banner.
344 # Make sure there is a space below the banner.
345 if self.log_level <= logging.INFO: print
345 if self.log_level <= logging.INFO: print
346
346
347 def _pylab_changed(self, name, old, new):
347 def _pylab_changed(self, name, old, new):
348 """Replace --pylab='inline' with --pylab='auto'"""
348 """Replace --pylab='inline' with --pylab='auto'"""
349 if new == 'inline':
349 if new == 'inline':
350 warn.warn("'inline' not available as pylab backend, "
350 warn.warn("'inline' not available as pylab backend, "
351 "using 'auto' instead.")
351 "using 'auto' instead.")
352 self.pylab = 'auto'
352 self.pylab = 'auto'
353
353
354 def start(self):
354 def start(self):
355 if self.subapp is not None:
355 if self.subapp is not None:
356 return self.subapp.start()
356 return self.subapp.start()
357 # perform any prexec steps:
357 # perform any prexec steps:
358 if self.interact:
358 if self.interact:
359 self.log.debug("Starting IPython's mainloop...")
359 self.log.debug("Starting IPython's mainloop...")
360 self.shell.mainloop()
360 self.shell.mainloop()
361 else:
361 else:
362 self.log.debug("IPython not interactive...")
362 self.log.debug("IPython not interactive...")
363
363
364
364
365 def load_default_config(ipython_dir=None):
365 def load_default_config(ipython_dir=None):
366 """Load the default config file from the default ipython_dir.
366 """Load the default config file from the default ipython_dir.
367
367
368 This is useful for embedded shells.
368 This is useful for embedded shells.
369 """
369 """
370 if ipython_dir is None:
370 if ipython_dir is None:
371 ipython_dir = get_ipython_dir()
371 ipython_dir = get_ipython_dir()
372 profile_dir = os.path.join(ipython_dir, 'profile_default')
372 profile_dir = os.path.join(ipython_dir, 'profile_default')
373 cl = PyFileConfigLoader("ipython_config.py", profile_dir)
373 cl = PyFileConfigLoader("ipython_config.py", profile_dir)
374 try:
374 try:
375 config = cl.load_config()
375 config = cl.load_config()
376 except ConfigFileNotFound:
376 except ConfigFileNotFound:
377 # no config found
377 # no config found
378 config = Config()
378 config = Config()
379 return config
379 return config
380
380
381
381
382 launch_new_instance = TerminalIPythonApp.launch_instance
382 launch_new_instance = TerminalIPythonApp.launch_instance
383
383
384
384
385 if __name__ == '__main__':
385 if __name__ == '__main__':
386 launch_new_instance()
386 launch_new_instance()
General Comments 0
You need to be logged in to leave comments. Login now