##// END OF EJS Templates
update copyright to 2011/20xx-2011...
update copyright to 2011/20xx-2011 Closes #1033 (rebased to prevent recursive merge). Closes #2. 459 *.py files in : 39 empty files 176 files without copyright 36 have copyright but don't cite the dev team 208 have copyright and cite the dev team ----------------------------------------- 0 not up to date (cite dev team but not right year) FYI, list of files that don't have copyright (and are not empty..) [ 'IPython/config/profile/cluster/ipython_config.py', 'IPython/config/profile/math/ipython_config.py', 'IPython/config/profile/pylab/ipython_config.py', 'IPython/config/profile/pysh/ipython_config.py', 'IPython/config/profile/python3/ipython_config.py', 'IPython/config/profile/sympy/ipython_config.py', 'IPython/core/shadowns.py', 'IPython/core/tests/refbug.py', 'IPython/core/tests/simpleerr.py', 'IPython/core/tests/tclass.py', 'IPython/core/tests/test_application.py', 'IPython/core/tests/test_autocall.py', 'IPython/core/tests/test_completer.py', 'IPython/core/tests/test_fakemodule.py', 'IPython/core/tests/test_formatters.py', 'IPython/core/tests/test_handlers.py', 'IPython/core/tests/test_history.py', 'IPython/core/tests/test_imports.py', 'IPython/core/tests/test_iplib.py', 'IPython/core/tests/test_logger.py', 'IPython/core/tests/test_magic.py', 'IPython/core/tests/test_plugin.py', 'IPython/core/tests/test_prefilter.py', 'IPython/core/tests/test_profile.py', 'IPython/core/tests/test_run.py', 'IPython/core/tests/test_splitinput.py', 'IPython/deathrow/astyle.py', 'IPython/deathrow/dtutils.py', 'IPython/deathrow/Gnuplot2.py', 'IPython/deathrow/GnuplotInteractive.py', 'IPython/deathrow/GnuplotRuntime.py', 'IPython/deathrow/gui/wx/ipshell_nonblocking.py', 'IPython/deathrow/gui/wx/ipython_history.py', 'IPython/deathrow/gui/wx/thread_ex.py', 'IPython/deathrow/ibrowse.py', 'IPython/deathrow/igrid.py', 'IPython/deathrow/ipipe.py', 'IPython/deathrow/ipy_defaults.py', 'IPython/deathrow/ipy_kitcfg.py', 'IPython/deathrow/ipy_legacy.py', 'IPython/deathrow/ipy_p4.py', 'IPython/deathrow/ipy_profile_none.py', 'IPython/deathrow/ipy_profile_numpy.py', 'IPython/deathrow/ipy_profile_scipy.py', 'IPython/deathrow/ipy_profile_sh.py', 'IPython/deathrow/ipy_traits_completer.py', 'IPython/deathrow/ipy_vimserver.py', 'IPython/deathrow/numeric_formats.py', 'IPython/deathrow/oldfrontend/process/__init__.py', 'IPython/deathrow/oldfrontend/wx/ipythonx.py', 'IPython/deathrow/scitedirector.py', 'IPython/deathrow/tests/test_prefilter.py', 'IPython/deathrow/twshell.py', 'IPython/extensions/__init__.py', 'IPython/extensions/autoreload.py', 'IPython/extensions/storemagic.py', 'IPython/extensions/tests/test_autoreload.py', 'IPython/external/__init__.py', 'IPython/external/argparse/__init__.py', 'IPython/external/decorator/__init__.py', 'IPython/external/decorators/__init__.py', 'IPython/external/decorators/_decorators.py', 'IPython/external/decorators/_numpy_testing_noseclasses.py', 'IPython/external/decorators/_numpy_testing_utils.py', 'IPython/external/guid/__init__.py', 'IPython/external/Itpl/__init__.py', 'IPython/external/mglob/__init__.py', 'IPython/external/mglob/_mglob.py', 'IPython/external/path/__init__.py', 'IPython/external/path/_path.py', 'IPython/external/pexpect/__init__.py', 'IPython/external/pyparsing/__init__.py', 'IPython/external/qt.py', 'IPython/external/qt_for_kernel.py', 'IPython/external/simplegeneric/__init__.py', 'IPython/external/simplegeneric/_simplegeneric.py', 'IPython/frontend/html/notebook/__init__.py', 'IPython/frontend/html/notebook/tests/test_kernelsession.py', 'IPython/frontend/qt/base_frontend_mixin.py', 'IPython/frontend/qt/console/ansi_code_processor.py', 'IPython/frontend/qt/console/bracket_matcher.py', 'IPython/frontend/qt/console/call_tip_widget.py', 'IPython/frontend/qt/console/completion_lexer.py', 'IPython/frontend/qt/console/completion_widget.py', 'IPython/frontend/qt/console/console_widget.py', 'IPython/frontend/qt/console/history_console_widget.py', 'IPython/frontend/qt/console/ipython_widget.py', 'IPython/frontend/qt/console/kill_ring.py', 'IPython/frontend/qt/console/mainwindow.py', 'IPython/frontend/qt/console/pygments_highlighter.py', 'IPython/frontend/qt/console/qtconsoleapp.py', 'IPython/frontend/qt/console/rich_ipython_widget.py', 'IPython/frontend/qt/console/styles.py', 'IPython/frontend/qt/console/tests/test_ansi_code_processor.py', 'IPython/frontend/qt/console/tests/test_completion_lexer.py', 'IPython/frontend/qt/console/tests/test_kill_ring.py', 'IPython/frontend/qt/kernelmanager.py', 'IPython/frontend/qt/rich_text.py', 'IPython/frontend/qt/svg.py', 'IPython/frontend/qt/util.py', 'IPython/kernel/__init__.py', 'IPython/lib/clipboard.py', 'IPython/lib/display.py', 'IPython/lib/irunner.py', 'IPython/lib/security.py', 'IPython/lib/tests/test_imports.py', 'IPython/lib/tests/test_irunner.py', 'IPython/lib/tests/test_irunner_pylab_magic.py', 'IPython/lib/tests/test_security.py', 'IPython/nbformat/v1/tests/nbexamples.py', 'IPython/nbformat/v1/tests/test_json.py', 'IPython/nbformat/v1/tests/test_nbbase.py', 'IPython/nbformat/v2/tests/nbexamples.py', 'IPython/nbformat/v2/tests/test_json.py', 'IPython/nbformat/v2/tests/test_nbbase.py', 'IPython/nbformat/v2/tests/test_nbpy.py', 'IPython/quarantine/clearcmd.py', 'IPython/quarantine/envpersist.py', 'IPython/quarantine/ext_rescapture.py', 'IPython/quarantine/ipy_app_completers.py', 'IPython/quarantine/ipy_completers.py', 'IPython/quarantine/ipy_editors.py', 'IPython/quarantine/ipy_exportdb.py', 'IPython/quarantine/ipy_extutil.py', 'IPython/quarantine/ipy_fsops.py', 'IPython/quarantine/ipy_gnuglobal.py', 'IPython/quarantine/ipy_jot.py', 'IPython/quarantine/ipy_lookfor.py', 'IPython/quarantine/ipy_profile_doctest.py', 'IPython/quarantine/ipy_pydb.py', 'IPython/quarantine/ipy_rehashdir.py', 'IPython/quarantine/ipy_render.py', 'IPython/quarantine/ipy_server.py', 'IPython/quarantine/ipy_signals.py', 'IPython/quarantine/ipy_synchronize_with.py', 'IPython/quarantine/ipy_system_conf.py', 'IPython/quarantine/ipy_which.py', 'IPython/quarantine/ipy_winpdb.py', 'IPython/quarantine/ipy_workdir.py', 'IPython/quarantine/jobctrl.py', 'IPython/quarantine/ledit.py', 'IPython/quarantine/win32clip.py', 'IPython/testing/mkdoctests.py', 'IPython/testing/plugin/dtexample.py', 'IPython/testing/plugin/ipdoctest.py', 'IPython/testing/plugin/iptest.py', 'IPython/testing/plugin/setup.py', 'IPython/testing/plugin/show_refs.py', 'IPython/testing/plugin/simple.py', 'IPython/testing/plugin/simplevars.py', 'IPython/testing/plugin/test_ipdoctest.py', 'IPython/testing/plugin/test_refs.py', 'IPython/testing/skipdoctest.py', 'IPython/testing/tests/test_decorators.py', 'IPython/utils/autoattr.py', 'IPython/utils/nested_context.py', 'IPython/utils/pickleshare.py', 'IPython/utils/py3compat.py', 'IPython/utils/PyColorize.py', 'IPython/utils/rlineimpl.py', 'IPython/utils/strdispatch.py', 'IPython/utils/tempdir.py', 'IPython/utils/tests/test_imports.py', 'IPython/utils/tests/test_wildcard.py', 'IPython/utils/upgradedir.py', 'IPython/zmq/completer.py', 'IPython/zmq/displayhook.py', 'IPython/zmq/entry_point.py', 'IPython/zmq/frontend.py', 'IPython/zmq/iostream.py', 'IPython/zmq/ipkernel.py', 'IPython/zmq/log.py', 'IPython/zmq/parentpoller.py', 'IPython/zmq/pykernel.py', 'IPython/zmq/pylab/backend_inline.py', 'IPython/zmq/zmqshell.py' ]

File last commit:

r5390:c82649ea
r5390:c82649ea
Show More
ipapp.py
397 lines | 14.2 KiB | text/x-python | PythonLexer
Brian Granger
Massive, crazy refactoring of everything....
r2202 #!/usr/bin/env python
# encoding: utf-8
"""
MinRK
rename core.newapplication -> core.application
r4023 The :class:`~IPython.core.application.Application` object for the command
Brian Granger
ipcontroller/ipengine use the new clusterdir.py module.
r2301 line :command:`ipython` program.
Brian Granger
Massive, crazy refactoring of everything....
r2202
Fernando Perez
Unify command-line usage information in one place....
r2427 Authors
-------
Brian Granger
Massive, crazy refactoring of everything....
r2202
* Brian Granger
* Fernando Perez
MinRK
Terminal IPython working with newapp
r3963 * Min Ragan-Kelley
Brian Granger
Massive, crazy refactoring of everything....
r2202 """
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Brian Granger
Massive, crazy refactoring of everything....
r2202 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Brian Granger
More work on the crash handler....
r2506
Fernando Perez
Unify command-line usage information in one place....
r2427 from __future__ import absolute_import
Brian Granger
Massive, crazy refactoring of everything....
r2202
Brian Granger
Work on startup related things....
r2252 import logging
Brian Granger
More work on getting rid of ipmaker.
r2203 import os
import sys
MinRK
Terminal IPython working with newapp
r3963 from IPython.config.loader import (
MinRK
catch ConfigFileNotFound where appropriate...
r4909 Config, PyFileConfigLoader, ConfigFileNotFound
MinRK
Terminal IPython working with newapp
r3963 )
MinRK
catch_config -> catch_config_error
r5214 from IPython.config.application import boolean_flag, catch_config_error
Brian Granger
More work on the crash handler....
r2506 from IPython.core import release
MinRK
Terminal IPython working with newapp
r3963 from IPython.core import usage
MinRK
move completer configurables to IPCompleter where they belong...
r5231 from IPython.core.completer import IPCompleter
Brian Granger
More work on the crash handler....
r2506 from IPython.core.crashhandler import CrashHandler
MinRK
Terminal IPython working with newapp
r3963 from IPython.core.formatters import PlainTextFormatter
MinRK
rename core.newapplication -> core.application
r4023 from IPython.core.application import (
MinRK
Terminal IPython working with newapp
r3963 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
Brian Granger
Massive refactoring of of the core....
r2245 )
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 from IPython.core.shellapp import (
InteractiveShellApp, shell_flags, shell_aliases
)
MinRK
Terminal IPython working with newapp
r3963 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
Brian Granger
Reenabled -wthread/-q4thread/-gthread and added warning for -pylab....
r2264 from IPython.lib import inputhook
MinRK
support `-pylab` flag with deprecation warning...
r4104 from IPython.utils import warn
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 from IPython.utils.path import get_ipython_dir, check_for_old_config
MinRK
Terminal IPython working with newapp
r3963 from IPython.utils.traitlets import (
MinRK
move InteractiveShellApp before TerminalIPythonApp in TerminalApp class list...
r4462 Bool, List, Dict, CaselessStrEnum
MinRK
Terminal IPython working with newapp
r3963 )
Brian Granger
More work on getting rid of ipmaker.
r2203
#-----------------------------------------------------------------------------
Fernando Perez
Unify command-line usage information in one place....
r2427 # Globals, utilities and helpers
Brian Granger
More work on getting rid of ipmaker.
r2203 #-----------------------------------------------------------------------------
Brian Granger
Refactored the command line config system and other aspects of config....
r2501 #: The default config file name for this application.
Fernando Perez
Unify command-line usage information in one place....
r2427 default_config_file_name = u'ipython_config.py'
Brian Granger
More work on getting rid of ipmaker.
r2203
Brian Granger
More work on adding examples to help strings.
r4216 _examples = """
ipython --pylab # start in pylab mode
ipython --pylab=qt # start in pylab mode with the qt4 backend
Brian E. Granger
Fixing command line options and help strings to use new syntax....
r4219 ipython --log-level=DEBUG # set logging to DEBUG
Brian Granger
More work on adding examples to help strings.
r4216 ipython --profile=foo # start with profile foo
Brian E. Granger
Finishing up help string work.
r4218
Brian Granger
More work on adding examples to help strings.
r4216 ipython qtconsole # start the qtconsole GUI application
ipython qtconsole -h # show the help string for the qtconsole subcmd
Brian E. Granger
Finishing up help string work.
r4218
ipython profile create foo # create profile foo w/ default config files
ipython profile -h # show the help string for the profile subcmd
Brian Granger
More work on adding examples to help strings.
r4216 """
Brian Granger
Refactored the command line config system and other aspects of config....
r2501
Fernando Perez
Unify command-line usage information in one place....
r2427 #-----------------------------------------------------------------------------
Brian Granger
More work on the crash handler....
r2506 # Crash handler for this application
#-----------------------------------------------------------------------------
class IPAppCrashHandler(CrashHandler):
"""sys.excepthook for IPython itself, leaves a detailed report on disk."""
def __init__(self, app):
contact_name = release.authors['Fernando'][0]
MinRK
use ipython-dev as the email address for crash reports
r5316 contact_email = release.author_email
bug_tracker = 'https://github.com/ipython/ipython/issues'
Brian Granger
More work on the crash handler....
r2506 super(IPAppCrashHandler,self).__init__(
app, contact_name, contact_email, bug_tracker
)
def make_report(self,traceback):
"""Return a string containing a crash report."""
sec_sep = self.section_sep
# Start with parent report
report = [super(IPAppCrashHandler, self).make_report(traceback)]
# Add interactive-specific info we may have
rpt_add = report.append
try:
rpt_add(sec_sep+"History of session input:")
for line in self.app.shell.user_ns['_ih']:
rpt_add(line)
rpt_add('\n*** Last line of input (may not be in above history):\n')
rpt_add(self.app.shell._last_input_line+'\n')
except:
pass
return ''.join(report)
MinRK
Terminal IPython working with newapp
r3963 #-----------------------------------------------------------------------------
# Aliases and Flags
#-----------------------------------------------------------------------------
flags = dict(base_flags)
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 flags.update(shell_flags)
MinRK
Terminal IPython working with newapp
r3963 addflag = lambda *args: flags.update(boolean_flag(*args))
addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
'Turn on auto editing of files with syntax errors.',
'Turn off auto editing of files with syntax errors.'
)
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 addflag('banner', 'TerminalIPythonApp.display_banner',
MinRK
Terminal IPython working with newapp
r3963 "Display a banner upon starting IPython.",
"Don't display a banner upon starting IPython."
)
addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
"""Set to confirm when you try to exit IPython with an EOF (Control-D
MinRK
minor helpstring cleanup per review.
r3967 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
you can force a direct exit without any confirmation.""",
MinRK
Terminal IPython working with newapp
r3963 "Don't prompt the user when exiting."
)
addflag('term-title', 'TerminalInteractiveShell.term_title',
"Enable auto setting the terminal title.",
"Disable auto setting the terminal title."
)
classic_config = Config()
classic_config.InteractiveShell.cache_size = 0
classic_config.PlainTextFormatter.pprint = False
classic_config.InteractiveShell.prompt_in1 = '>>> '
classic_config.InteractiveShell.prompt_in2 = '... '
classic_config.InteractiveShell.prompt_out = ''
classic_config.InteractiveShell.separate_in = ''
classic_config.InteractiveShell.separate_out = ''
classic_config.InteractiveShell.separate_out2 = ''
classic_config.InteractiveShell.colors = 'NoColor'
classic_config.InteractiveShell.xmode = 'Plain'
flags['classic']=(
classic_config,
"Gives IPython a similar feel to the classic Python prompt."
)
# # log doesn't make so much sense this way anymore
# paa('--log','-l',
# action='store_true', dest='InteractiveShell.logstart',
# help="Start logging to the default log file (./ipython_log.py).")
#
# # quick is harder to implement
flags['quick']=(
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 {'TerminalIPythonApp' : {'quick' : True}},
MinRK
Terminal IPython working with newapp
r3963 "Enable quick startup with no config files."
)
flags['i'] = (
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 {'TerminalIPythonApp' : {'force_interact' : True}},
Fernando Perez
Cleanup -pylab handling with faster logic.
r4245 """If running code from the command line, become interactive afterwards.
Note: can also be given simply as '-i.'"""
MinRK
Terminal IPython working with newapp
r3963 )
flags['pylab'] = (
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 {'TerminalIPythonApp' : {'pylab' : 'auto'}},
MinRK
Terminal IPython working with newapp
r3963 """Pre-load matplotlib and numpy for interactive use with
the default matplotlib backend."""
)
aliases = dict(base_aliases)
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 aliases.update(shell_aliases)
MinRK
Terminal IPython working with newapp
r3963
# it's possible we don't want short aliases for *all* of these:
aliases.update(dict(
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 gui='TerminalIPythonApp.gui',
pylab='TerminalIPythonApp.pylab',
MinRK
Terminal IPython working with newapp
r3963 ))
Brian Granger
More work on the crash handler....
r2506
#-----------------------------------------------------------------------------
Fernando Perez
Unify command-line usage information in one place....
r2427 # Main classes and functions
#-----------------------------------------------------------------------------
Brian Granger
Massive refactoring of of the core....
r2245
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
Brian Granger
Beginning to transition all paths, files, dirs over to unicode....
r2328 name = u'ipython'
MinRK
Terminal IPython working with newapp
r3963 description = usage.cl_usage
Brian Granger
Various fixes to ipapp/ipcluster/ipengine/ipcontroller....
r2511 default_config_file_name = default_config_file_name
Brian Granger
More work on the crash handler....
r2506 crash_handler_class = IPAppCrashHandler
Brian Granger
More work on adding examples to help strings.
r4216 examples = _examples
Brian Granger
Command line examples added for non-parallel apps.
r4215
MinRK
Terminal IPython working with newapp
r3963 flags = Dict(flags)
aliases = Dict(aliases)
MinRK
move InteractiveShellApp before TerminalIPythonApp in TerminalApp class list...
r4462 classes = List()
def _classes_default(self):
"""This has to be in a method, for TerminalIPythonApp to be available."""
return [
InteractiveShellApp, # ShellApp comes before TerminalApp, because
self.__class__, # it will also affect subclasses (e.g. QtConsole)
TerminalInteractiveShell,
ProfileDir,
PlainTextFormatter,
MinRK
move completer configurables to IPCompleter where they belong...
r5231 IPCompleter,
MinRK
move InteractiveShellApp before TerminalIPythonApp in TerminalApp class list...
r4462 ]
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
add qtconsole as subapp of terminal ipapp...
r3982 subcommands = Dict(dict(
MinRK
rename ipythonqt to qtconsoleapp...
r4022 qtconsole=('IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp',
"""Launch the IPython Qt Console."""
MinRK
move ipcluster create|list to `ipython profile create|list`...
r4024 ),
Brian E. Granger
Misc changes to the notebook....
r5104 notebook=('IPython.frontend.html.notebook.notebookapp.NotebookApp',
Brian E. Granger
Refactoring the notebook app to support the new config system.
r4344 """Launch the IPython HTML Notebook Server"""
),
MinRK
move ipcluster create|list to `ipython profile create|list`...
r4024 profile = ("IPython.core.profileapp.ProfileApp",
MinRK
add 'ipython kernel' entry point...
r4501 "Create and manage IPython profiles."
),
kernel = ("IPython.zmq.ipkernel.IPKernelApp",
"Start a kernel without an attached frontend."
),
MinRK
add qtconsole as subapp of terminal ipapp...
r3982 ))
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
default config files are automatically generated...
r4025 # *do* autocreate requested profile, but don't create the config file.
MinRK
Terminal IPython working with newapp
r3963 auto_create=Bool(True)
# configurables
ignore_old_config=Bool(False, config=True,
help="Suppress warning messages about legacy config files"
)
quick = Bool(False, config=True,
help="""Start IPython quickly by skipping the loading of config files."""
)
def _quick_changed(self, name, old, new):
if new:
self.load_config_file = lambda *a, **kw: None
self.ignore_old_config=True
Nicolas Rougier
Added the command line option
r4814 gui = CaselessStrEnum(('qt', 'wx', 'gtk', 'glut', 'pyglet'), config=True,
help="Enable GUI event loop integration ('qt', 'wx', 'gtk', 'glut', 'pyglet')."
MinRK
Terminal IPython working with newapp
r3963 )
pylab = CaselessStrEnum(['tk', 'qt', 'wx', 'gtk', 'osx', 'auto'],
config=True,
help="""Pre-load matplotlib and numpy for interactive use,
selecting a particular matplotlib backend and loop integration.
"""
)
display_banner = Bool(True, config=True,
help="Whether to display a banner upon starting IPython."
)
# if there is code of files to run from the cmd line, don't interact
# unless the --i flag (App.force_interact) is true.
force_interact = Bool(False, config=True,
help="""If a command or file is given via the command-line,
e.g. 'ipython foo.py"""
)
def _force_interact_changed(self, name, old, new):
if new:
self.interact = True
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
Terminal IPython working with newapp
r3963 def _file_to_run_changed(self, name, old, new):
if new and not self.force_interact:
self.interact = False
_code_to_run_changed = _file_to_run_changed
# internal, not-configurable
interact=Bool(True)
MinRK
support `-pylab` flag with deprecation warning...
r4104 def parse_command_line(self, argv=None):
"""override to allow old '-pylab' flag with deprecation warning"""
Fernando Perez
Cleanup -pylab handling with faster logic.
r4245
MinRK
support `-pylab` flag with deprecation warning...
r4104 argv = sys.argv[1:] if argv is None else argv
Fernando Perez
Cleanup -pylab handling with faster logic.
r4245
if '-pylab' in argv:
MinRK
support `-pylab` flag with deprecation warning...
r4104 # deprecated `-pylab` given,
# warn and transform into current syntax
Fernando Perez
Cleanup -pylab handling with faster logic.
r4245 argv = argv[:] # copy, don't clobber
idx = argv.index('-pylab')
MinRK
support `-pylab` flag with deprecation warning...
r4104 warn.warn("`-pylab` flag has been deprecated.\n"
MinRK
update '-pylab' deprecation message to new pattern.
r4190 " Use `--pylab` instead, or `--pylab=foo` to specify a backend.")
MinRK
support `-pylab` flag with deprecation warning...
r4104 sub = '--pylab'
if len(argv) > idx+1:
# check for gui arg, as in '-pylab qt'
gui = argv[idx+1]
if gui in ('wx', 'qt', 'qt4', 'gtk', 'auto'):
MinRK
update '-pylab' deprecation message to new pattern.
r4190 sub = '--pylab='+gui
MinRK
support `-pylab` flag with deprecation warning...
r4104 argv.pop(idx+1)
argv[idx] = sub
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
support `-pylab` flag with deprecation warning...
r4104 return super(TerminalIPythonApp, self).parse_command_line(argv)
MinRK
Show invalid config message on TraitErrors during initialization...
r5172
MinRK
catch_config -> catch_config_error
r5214 @catch_config_error
MinRK
Terminal IPython working with newapp
r3963 def initialize(self, argv=None):
"""Do actions after construct, but before starting the app."""
MinRK
Split generic part of terminal frontend/terminal/ipapp into core/shellapp...
r3968 super(TerminalIPythonApp, self).initialize(argv)
MinRK
add qtconsole as subapp of terminal ipapp...
r3982 if self.subapp is not None:
# don't bother initializing further, starting subapp
return
MinRK
Terminal IPython working with newapp
r3963 if not self.ignore_old_config:
check_for_old_config(self.ipython_dir)
# print self.extra_args
if self.extra_args:
self.file_to_run = self.extra_args[0]
# create the shell
self.init_shell()
# and draw the banner
self.init_banner()
# Now a variety of things that happen after the banner is printed.
self.init_gui_pylab()
self.init_extensions()
self.init_code()
def init_shell(self):
"""initialize the InteractiveShell instance"""
Brian Granger
More work on getting rid of ipmaker.
r2203 # I am a little hesitant to put these into InteractiveShell itself.
# But that might be the place for them
sys.path.insert(0, '')
Brian Granger
Work on startup related things....
r2252
Brian Granger
First draft of refactored Component->Configurable.
r2731 # Create an InteractiveShell instance.
Bernardo B. Marques
remove all trailling spaces
r4872 # shell.display_banner should always be False for the terminal
Brian Granger
Work on startup related things....
r2252 # based app, because we call shell.show_banner() by hand below
# so the banner shows *before* all extension loading stuff.
MinRK
Terminal IPython working with newapp
r3963 self.shell = TerminalInteractiveShell.instance(config=self.config,
display_banner=False, profile_dir=self.profile_dir,
ipython_dir=self.ipython_dir)
MinRK
include parent Application in InteractiveShell.configurables...
r5315 self.shell.configurables.append(self)
Brian Granger
Work on startup related things....
r2252
MinRK
Terminal IPython working with newapp
r3963 def init_banner(self):
"""optionally display the banner"""
if self.display_banner and self.interact:
self.shell.show_banner()
Brian Granger
Work on startup related things....
r2252 # Make sure there is a space below the banner.
if self.log_level <= logging.INFO: print
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
MinRK
Terminal IPython working with newapp
r3963 def init_gui_pylab(self):
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 """Enable GUI event loop integration, taking pylab into account."""
MinRK
Terminal IPython working with newapp
r3963 gui = self.gui
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
MinRK
Terminal IPython working with newapp
r3963 # Using `pylab` will also require gui activation, though which toolkit
Fernando Perez
Added --gui to match %gui use, better docs and behavior for %pylab code....
r2388 # to use may be chosen automatically based on mpl configuration.
MinRK
Terminal IPython working with newapp
r3963 if self.pylab:
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 activate = self.shell.enable_pylab
MinRK
Terminal IPython working with newapp
r3963 if self.pylab == 'auto':
Fernando Perez
Added --gui to match %gui use, better docs and behavior for %pylab code....
r2388 gui = None
else:
MinRK
Terminal IPython working with newapp
r3963 gui = self.pylab
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 else:
# Enable only GUI integration, no pylab
activate = inputhook.enable_gui
MinRK
Terminal IPython working with newapp
r3963 if gui or self.pylab:
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 try:
Fernando Perez
Added --gui to match %gui use, better docs and behavior for %pylab code....
r2388 self.log.info("Enabling GUI event loop integration, "
MinRK
Terminal IPython working with newapp
r3963 "toolkit=%s, pylab=%s" % (gui, self.pylab) )
Jens Hedegaard Nielsen
Make import_all configurable in InteractiveShellApp
r4787 if self.pylab:
activate(gui, import_all=self.pylab_import_all)
else:
activate(gui)
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363 except:
self.log.warn("Error in enabling GUI event loop integration:")
self.shell.showtraceback()
Brian Granger
Work on startup related things....
r2252
MinRK
Terminal IPython working with newapp
r3963 def start(self):
MinRK
add qtconsole as subapp of terminal ipapp...
r3982 if self.subapp is not None:
return self.subapp.start()
MinRK
Terminal IPython working with newapp
r3963 # perform any prexec steps:
if self.interact:
Brian Granger
All code startup related things are working....
r2253 self.log.debug("Starting IPython's mainloop...")
self.shell.mainloop()
Fernando Perez
Manage and propagate argv correctly....
r2391 else:
MinRK
Terminal IPython working with newapp
r3963 self.log.debug("IPython not interactive...")
Brian Granger
Massive, crazy refactoring of everything....
r2202
Fernando Perez
First semi-complete support for -pylab and %pylab....
r2363
Brian Granger
Lots of work on command line options and env vars....
r2322 def load_default_config(ipython_dir=None):
"""Load the default config file from the default ipython_dir.
Brian Granger
Massive refactoring of of the core....
r2245
This is useful for embedded shells.
"""
Brian Granger
Lots of work on command line options and env vars....
r2322 if ipython_dir is None:
ipython_dir = get_ipython_dir()
MinRK
Terminal IPython working with newapp
r3963 profile_dir = os.path.join(ipython_dir, 'profile_default')
cl = PyFileConfigLoader(default_config_file_name, profile_dir)
MinRK
don't let missing config prevent embed from launching...
r4168 try:
config = cl.load_config()
MinRK
catch ConfigFileNotFound where appropriate...
r4909 except ConfigFileNotFound:
MinRK
don't let missing config prevent embed from launching...
r4168 # no config found
config = Config()
Brian Granger
Massive refactoring of of the core....
r2245 return config
Brian Granger
Removed ipapi compatability layer and updated top-level functions....
r2269 def launch_new_instance():
Brian Granger
Work on ipcontroller....
r2296 """Create and run a full blown IPython instance"""
MinRK
use App.instance() in launch_new_instance...
r3969 app = TerminalIPythonApp.instance()
MinRK
Terminal IPython working with newapp
r3963 app.initialize()
Brian Granger
Removed ipapi compatability layer and updated top-level functions....
r2269 app.start()
Brian Granger
Refactored the command line config system and other aspects of config....
r2501
Brian Granger
Removed the top-level iptest.py and INSTALLED logic....
r2507
if __name__ == '__main__':
launch_new_instance()