##// END OF EJS Templates
update release/authors...
MinRK -
Show More
@@ -1,87 +1,85 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 IPython: tools for interactive and parallel computing in Python.
3 IPython: tools for interactive and parallel computing in Python.
4
4
5 http://ipython.org
5 http://ipython.org
6 """
6 """
7 #-----------------------------------------------------------------------------
7 #-----------------------------------------------------------------------------
8 # Copyright (c) 2008-2011, IPython Development Team.
8 # Copyright (c) 2008-2011, IPython Development Team.
9 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
9 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
10 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
10 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
11 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
11 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
12 #
12 #
13 # Distributed under the terms of the Modified BSD License.
13 # Distributed under the terms of the Modified BSD License.
14 #
14 #
15 # The full license is in the file COPYING.txt, distributed with this software.
15 # The full license is in the file COPYING.txt, distributed with this software.
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19 # Imports
19 # Imports
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 from __future__ import absolute_import
21 from __future__ import absolute_import
22
22
23 import os
23 import os
24 import sys
24 import sys
25
25
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27 # Setup everything
27 # Setup everything
28 #-----------------------------------------------------------------------------
28 #-----------------------------------------------------------------------------
29
29
30 # Don't forget to also update setup.py when this changes!
30 # Don't forget to also update setup.py when this changes!
31 if sys.version[0:3] < '2.6':
31 if sys.version[0:3] < '2.6':
32 raise ImportError('Python Version 2.6 or above is required for IPython.')
32 raise ImportError('Python Version 2.6 or above is required for IPython.')
33
33
34 # Make it easy to import extensions - they are always directly on pythonpath.
34 # Make it easy to import extensions - they are always directly on pythonpath.
35 # Therefore, non-IPython modules can be added to extensions directory.
35 # Therefore, non-IPython modules can be added to extensions directory.
36 # This should probably be in ipapp.py.
36 # This should probably be in ipapp.py.
37 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
37 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
38
38
39 #-----------------------------------------------------------------------------
39 #-----------------------------------------------------------------------------
40 # Setup the top level names
40 # Setup the top level names
41 #-----------------------------------------------------------------------------
41 #-----------------------------------------------------------------------------
42
42
43 from .config.loader import Config
43 from .config.loader import Config
44 from .core import release
44 from .core import release
45 from .core.application import Application
45 from .core.application import Application
46 from .frontend.terminal.embed import embed
46 from .frontend.terminal.embed import embed
47
47
48 from .core.error import TryNext
48 from .core.error import TryNext
49 from .core.interactiveshell import InteractiveShell
49 from .core.interactiveshell import InteractiveShell
50 from .testing import test
50 from .testing import test
51 from .utils.sysinfo import sys_info
51 from .utils.sysinfo import sys_info
52 from .utils.frame import extract_module_locals
52 from .utils.frame import extract_module_locals
53
53
54 # Release data
54 # Release data
55 __author__ = ''
55 __author__ = '%s <%s>' % (release.author, release.author_email)
56 for author, email in release.authors.itervalues():
57 __author__ += author + ' <' + email + '>\n'
58 __license__ = release.license
56 __license__ = release.license
59 __version__ = release.version
57 __version__ = release.version
60 version_info = release.version_info
58 version_info = release.version_info
61
59
62 def embed_kernel(module=None, local_ns=None, **kwargs):
60 def embed_kernel(module=None, local_ns=None, **kwargs):
63 """Embed and start an IPython kernel in a given scope.
61 """Embed and start an IPython kernel in a given scope.
64
62
65 Parameters
63 Parameters
66 ----------
64 ----------
67 module : ModuleType, optional
65 module : ModuleType, optional
68 The module to load into IPython globals (default: caller)
66 The module to load into IPython globals (default: caller)
69 local_ns : dict, optional
67 local_ns : dict, optional
70 The namespace to load into IPython user namespace (default: caller)
68 The namespace to load into IPython user namespace (default: caller)
71
69
72 kwargs : various, optional
70 kwargs : various, optional
73 Further keyword args are relayed to the KernelApp constructor,
71 Further keyword args are relayed to the KernelApp constructor,
74 allowing configuration of the Kernel. Will only have an effect
72 allowing configuration of the Kernel. Will only have an effect
75 on the first embed_kernel call for a given process.
73 on the first embed_kernel call for a given process.
76
74
77 """
75 """
78
76
79 (caller_module, caller_locals) = extract_module_locals(1)
77 (caller_module, caller_locals) = extract_module_locals(1)
80 if module is None:
78 if module is None:
81 module = caller_module
79 module = caller_module
82 if local_ns is None:
80 if local_ns is None:
83 local_ns = caller_locals
81 local_ns = caller_locals
84
82
85 # Only import .zmq when we really need it
83 # Only import .zmq when we really need it
86 from .zmq.ipkernel import embed_kernel as real_embed_kernel
84 from .zmq.ipkernel import embed_kernel as real_embed_kernel
87 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
85 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
@@ -1,151 +1,151 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project."""
2 """Release data for the IPython project."""
3
3
4 #-----------------------------------------------------------------------------
4 #-----------------------------------------------------------------------------
5 # Copyright (c) 2008, IPython Development Team.
5 # Copyright (c) 2008, IPython Development Team.
6 # Copyright (c) 2001, Fernando Perez <fernando.perez@colorado.edu>
6 # Copyright (c) 2001, Fernando Perez <fernando.perez@colorado.edu>
7 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
7 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
8 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
8 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
9 #
9 #
10 # Distributed under the terms of the Modified BSD License.
10 # Distributed under the terms of the Modified BSD License.
11 #
11 #
12 # The full license is in the file COPYING.txt, distributed with this software.
12 # The full license is in the file COPYING.txt, distributed with this software.
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 # Name of the package for release purposes. This is the name which labels
15 # Name of the package for release purposes. This is the name which labels
16 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
16 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
17 name = 'ipython'
17 name = 'ipython'
18
18
19 # IPython version information. An empty _version_extra corresponds to a full
19 # IPython version information. An empty _version_extra corresponds to a full
20 # release. 'dev' as a _version_extra string means this is a development
20 # release. 'dev' as a _version_extra string means this is a development
21 # version
21 # version
22 _version_major = 0
22 _version_major = 0
23 _version_minor = 14
23 _version_minor = 14
24 _version_micro = 0 # use 0 for first of series, number for 1 and above
24 _version_micro = 0 # use 0 for first of series, number for 1 and above
25 _version_extra = 'dev'
25 _version_extra = 'dev'
26 #_version_extra = 'rc1'
26 #_version_extra = 'rc1'
27 # _version_extra = '' # Uncomment this for full releases
27 # _version_extra = '' # Uncomment this for full releases
28
28
29 # Construct full version string from these.
29 # Construct full version string from these.
30 _ver = [_version_major, _version_minor]
30 _ver = [_version_major, _version_minor]
31 if _version_micro:
31 if _version_micro:
32 _ver.append(_version_micro)
32 _ver.append(_version_micro)
33 if _version_extra:
33 if _version_extra:
34 _ver.append(_version_extra)
34 _ver.append(_version_extra)
35
35
36 __version__ = '.'.join(map(str, _ver))
36 __version__ = '.'.join(map(str, _ver))
37
37
38 version = __version__ # backwards compatibility name
38 version = __version__ # backwards compatibility name
39 version_info = (_version_major, _version_minor, _version_micro, _version_extra)
39 version_info = (_version_major, _version_minor, _version_micro, _version_extra)
40
40
41 # Change this when incrementing the kernel protocol version
41 # Change this when incrementing the kernel protocol version
42 kernel_protocol_version_info = (4, 0)
42 kernel_protocol_version_info = (4, 0)
43
43
44 description = "IPython: Productive Interactive Computing"
44 description = "IPython: Productive Interactive Computing"
45
45
46 long_description = \
46 long_description = \
47 """
47 """
48 IPython provides a rich toolkit to help you make the most out of using Python
48 IPython provides a rich toolkit to help you make the most out of using Python
49 interactively. Its main components are:
49 interactively. Its main components are:
50
50
51 * Powerful interactive Python shells (terminal- and Qt-based).
51 * Powerful interactive Python shells (terminal- and Qt-based).
52 * A web-based interactive notebook environment with all shell features plus
52 * A web-based interactive notebook environment with all shell features plus
53 support for embedded figures, animations and rich media.
53 support for embedded figures, animations and rich media.
54 * Support for interactive data visualization and use of GUI toolkits.
54 * Support for interactive data visualization and use of GUI toolkits.
55 * Flexible, embeddable interpreters to load into your own projects.
55 * Flexible, embeddable interpreters to load into your own projects.
56 * A high-performance library for high level and interactive parallel computing
56 * A high-performance library for high level and interactive parallel computing
57 that works in multicore systems, clusters, supercomputing and cloud scenarios.
57 that works in multicore systems, clusters, supercomputing and cloud scenarios.
58
58
59 The enhanced interactive Python shells have the following main features:
59 The enhanced interactive Python shells have the following main features:
60
60
61 * Comprehensive object introspection.
61 * Comprehensive object introspection.
62
62
63 * Input history, persistent across sessions.
63 * Input history, persistent across sessions.
64
64
65 * Caching of output results during a session with automatically generated
65 * Caching of output results during a session with automatically generated
66 references.
66 references.
67
67
68 * Extensible tab completion, with support by default for completion of python
68 * Extensible tab completion, with support by default for completion of python
69 variables and keywords, filenames and function keywords.
69 variables and keywords, filenames and function keywords.
70
70
71 * Extensible system of 'magic' commands for controlling the environment and
71 * Extensible system of 'magic' commands for controlling the environment and
72 performing many tasks related either to IPython or the operating system.
72 performing many tasks related either to IPython or the operating system.
73
73
74 * A rich configuration system with easy switching between different setups
74 * A rich configuration system with easy switching between different setups
75 (simpler than changing $PYTHONSTARTUP environment variables every time).
75 (simpler than changing $PYTHONSTARTUP environment variables every time).
76
76
77 * Session logging and reloading.
77 * Session logging and reloading.
78
78
79 * Extensible syntax processing for special purpose situations.
79 * Extensible syntax processing for special purpose situations.
80
80
81 * Access to the system shell with user-extensible alias system.
81 * Access to the system shell with user-extensible alias system.
82
82
83 * Easily embeddable in other Python programs and GUIs.
83 * Easily embeddable in other Python programs and GUIs.
84
84
85 * Integrated access to the pdb debugger and the Python profiler.
85 * Integrated access to the pdb debugger and the Python profiler.
86
86
87 The parallel computing architecture has the following main features:
87 The parallel computing architecture has the following main features:
88
88
89 * Quickly parallelize Python code from an interactive Python/IPython session.
89 * Quickly parallelize Python code from an interactive Python/IPython session.
90
90
91 * A flexible and dynamic process model that be deployed on anything from
91 * A flexible and dynamic process model that be deployed on anything from
92 multicore workstations to supercomputers.
92 multicore workstations to supercomputers.
93
93
94 * An architecture that supports many different styles of parallelism, from
94 * An architecture that supports many different styles of parallelism, from
95 message passing to task farming.
95 message passing to task farming.
96
96
97 * Both blocking and fully asynchronous interfaces.
97 * Both blocking and fully asynchronous interfaces.
98
98
99 * High level APIs that enable many things to be parallelized in a few lines
99 * High level APIs that enable many things to be parallelized in a few lines
100 of code.
100 of code.
101
101
102 * Share live parallel jobs with other users securely.
102 * Share live parallel jobs with other users securely.
103
103
104 * Dynamically load balanced task farming system.
104 * Dynamically load balanced task farming system.
105
105
106 * Robust error handling in parallel code.
106 * Robust error handling in parallel code.
107
107
108 The latest development version is always available from IPython's `GitHub
108 The latest development version is always available from IPython's `GitHub
109 site <http://github.com/ipython>`_.
109 site <http://github.com/ipython>`_.
110 """
110 """
111
111
112 license = 'BSD'
112 license = 'BSD'
113
113
114 authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'),
114 authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'),
115 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
115 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
116 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
116 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
117 'Ville' : ('Ville Vainio','vivainio@gmail.com'),
117 'Ville' : ('Ville Vainio','vivainio@gmail.com'),
118 'Brian' : ('Brian E Granger', 'ellisonbg@gmail.com'),
118 'Brian' : ('Brian E Granger', 'ellisonbg@gmail.com'),
119 'Min' : ('Min Ragan-Kelley', 'benjaminrk@gmail.com'),
119 'Min' : ('Min Ragan-Kelley', 'benjaminrk@gmail.com'),
120 'Thomas' : ('Thomas A. Kluyver', 'takowl@gmail.com'),
120 'Thomas' : ('Thomas A. Kluyver', 'takowl@gmail.com'),
121 'Jorgen' : ('Jorgen Stenarson', 'jorgen.stenarson@bostream.nu'),
121 'Jorgen' : ('Jorgen Stenarson', 'jorgen.stenarson@bostream.nu'),
122 'Matthias' : ('Matthias Bussonnier', 'bussonniermatthias@gmail.com'),
122 'Matthias' : ('Matthias Bussonnier', 'bussonniermatthias@gmail.com'),
123 }
123 }
124
124
125 author = 'The IPython Development Team'
125 author = 'The IPython Development Team'
126
126
127 author_email = 'ipython-dev@scipy.org'
127 author_email = 'ipython-dev@scipy.org'
128
128
129 url = 'http://ipython.org'
129 url = 'http://ipython.org'
130
130
131 download_url = 'https://github.com/ipython/ipython/downloads'
131 download_url = 'https://github.com/ipython/ipython/downloads'
132
132
133 platforms = ['Linux','Mac OSX','Windows XP/2000/NT/Vista/7']
133 platforms = ['Linux','Mac OSX','Windows XP/Vista/7/8']
134
134
135 keywords = ['Interactive','Interpreter','Shell','Parallel','Distributed',
135 keywords = ['Interactive','Interpreter','Shell','Parallel','Distributed',
136 'Web-based computing', 'Qt console', 'Embedding']
136 'Web-based computing', 'Qt console', 'Embedding']
137
137
138 classifiers = [
138 classifiers = [
139 'Intended Audience :: Developers',
139 'Intended Audience :: Developers',
140 'Intended Audience :: Science/Research',
140 'Intended Audience :: Science/Research',
141 'License :: OSI Approved :: BSD License',
141 'License :: OSI Approved :: BSD License',
142 'Programming Language :: Python',
142 'Programming Language :: Python',
143 'Programming Language :: Python :: 2',
143 'Programming Language :: Python :: 2',
144 'Programming Language :: Python :: 2.6',
144 'Programming Language :: Python :: 2.6',
145 'Programming Language :: Python :: 2.7',
145 'Programming Language :: Python :: 2.7',
146 'Programming Language :: Python :: 3',
146 'Programming Language :: Python :: 3',
147 'Programming Language :: Python :: 3.1',
148 'Programming Language :: Python :: 3.2',
147 'Programming Language :: Python :: 3.2',
148 'Programming Language :: Python :: 3.3',
149 'Topic :: System :: Distributed Computing',
149 'Topic :: System :: Distributed Computing',
150 'Topic :: System :: Shells'
150 'Topic :: System :: Shells'
151 ]
151 ]
@@ -1,393 +1,393 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.frontend.terminal.interactiveshell import TerminalInteractiveShell
50 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
51 from IPython.lib import inputhook
51 from IPython.lib import inputhook
52 from IPython.utils import warn
52 from IPython.utils import warn
53 from IPython.utils.path import get_ipython_dir, check_for_old_config
53 from IPython.utils.path import get_ipython_dir, check_for_old_config
54 from IPython.utils.traitlets import (
54 from IPython.utils.traitlets import (
55 Bool, List, Dict, CaselessStrEnum
55 Bool, List, Dict, CaselessStrEnum
56 )
56 )
57
57
58 #-----------------------------------------------------------------------------
58 #-----------------------------------------------------------------------------
59 # Globals, utilities and helpers
59 # Globals, utilities and helpers
60 #-----------------------------------------------------------------------------
60 #-----------------------------------------------------------------------------
61
61
62 #: The default config file name for this application.
62 #: The default config file name for this application.
63 default_config_file_name = u'ipython_config.py'
63 default_config_file_name = u'ipython_config.py'
64
64
65 _examples = """
65 _examples = """
66 ipython --pylab # start in pylab mode
66 ipython --pylab # start in pylab mode
67 ipython --pylab=qt # start in pylab mode with the qt4 backend
67 ipython --pylab=qt # start in pylab mode with the qt4 backend
68 ipython --log-level=DEBUG # set logging to DEBUG
68 ipython --log-level=DEBUG # set logging to DEBUG
69 ipython --profile=foo # start with profile foo
69 ipython --profile=foo # start with profile foo
70
70
71 ipython qtconsole # start the qtconsole GUI application
71 ipython qtconsole # start the qtconsole GUI application
72 ipython help qtconsole # show the help for the qtconsole subcmd
72 ipython help qtconsole # show the help for the qtconsole subcmd
73
73
74 ipython console # start the terminal-based console application
74 ipython console # start the terminal-based console application
75 ipython help console # show the help for the console subcmd
75 ipython help console # show the help for the console subcmd
76
76
77 ipython notebook # start the IPython notebook
77 ipython notebook # start the IPython notebook
78 ipython help notebook # show the help for the notebook subcmd
78 ipython help notebook # show the help for the notebook subcmd
79
79
80 ipython profile create foo # create profile foo w/ default config files
80 ipython profile create foo # create profile foo w/ default config files
81 ipython help profile # show the help for the profile subcmd
81 ipython help profile # show the help for the profile subcmd
82
82
83 ipython locate # print the path to the IPython directory
83 ipython locate # print the path to the IPython directory
84 ipython locate profile foo # print the path to the directory for profile `foo`
84 ipython locate profile foo # print the path to the directory for profile `foo`
85 """
85 """
86
86
87 #-----------------------------------------------------------------------------
87 #-----------------------------------------------------------------------------
88 # Crash handler for this application
88 # Crash handler for this application
89 #-----------------------------------------------------------------------------
89 #-----------------------------------------------------------------------------
90
90
91 class IPAppCrashHandler(CrashHandler):
91 class IPAppCrashHandler(CrashHandler):
92 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
92 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
93
93
94 def __init__(self, app):
94 def __init__(self, app):
95 contact_name = release.authors['Fernando'][0]
95 contact_name = release.author
96 contact_email = release.author_email
96 contact_email = release.author_email
97 bug_tracker = 'https://github.com/ipython/ipython/issues'
97 bug_tracker = 'https://github.com/ipython/ipython/issues'
98 super(IPAppCrashHandler,self).__init__(
98 super(IPAppCrashHandler,self).__init__(
99 app, contact_name, contact_email, bug_tracker
99 app, contact_name, contact_email, bug_tracker
100 )
100 )
101
101
102 def make_report(self,traceback):
102 def make_report(self,traceback):
103 """Return a string containing a crash report."""
103 """Return a string containing a crash report."""
104
104
105 sec_sep = self.section_sep
105 sec_sep = self.section_sep
106 # Start with parent report
106 # Start with parent report
107 report = [super(IPAppCrashHandler, self).make_report(traceback)]
107 report = [super(IPAppCrashHandler, self).make_report(traceback)]
108 # Add interactive-specific info we may have
108 # Add interactive-specific info we may have
109 rpt_add = report.append
109 rpt_add = report.append
110 try:
110 try:
111 rpt_add(sec_sep+"History of session input:")
111 rpt_add(sec_sep+"History of session input:")
112 for line in self.app.shell.user_ns['_ih']:
112 for line in self.app.shell.user_ns['_ih']:
113 rpt_add(line)
113 rpt_add(line)
114 rpt_add('\n*** Last line of input (may not be in above history):\n')
114 rpt_add('\n*** Last line of input (may not be in above history):\n')
115 rpt_add(self.app.shell._last_input_line+'\n')
115 rpt_add(self.app.shell._last_input_line+'\n')
116 except:
116 except:
117 pass
117 pass
118
118
119 return ''.join(report)
119 return ''.join(report)
120
120
121 #-----------------------------------------------------------------------------
121 #-----------------------------------------------------------------------------
122 # Aliases and Flags
122 # Aliases and Flags
123 #-----------------------------------------------------------------------------
123 #-----------------------------------------------------------------------------
124 flags = dict(base_flags)
124 flags = dict(base_flags)
125 flags.update(shell_flags)
125 flags.update(shell_flags)
126 frontend_flags = {}
126 frontend_flags = {}
127 addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
127 addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
128 addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
128 addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
129 'Turn on auto editing of files with syntax errors.',
129 'Turn on auto editing of files with syntax errors.',
130 'Turn off auto editing of files with syntax errors.'
130 'Turn off auto editing of files with syntax errors.'
131 )
131 )
132 addflag('banner', 'TerminalIPythonApp.display_banner',
132 addflag('banner', 'TerminalIPythonApp.display_banner',
133 "Display a banner upon starting IPython.",
133 "Display a banner upon starting IPython.",
134 "Don't display a banner upon starting IPython."
134 "Don't display a banner upon starting IPython."
135 )
135 )
136 addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
136 addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
137 """Set to confirm when you try to exit IPython with an EOF (Control-D
137 """Set to confirm when you try to exit IPython with an EOF (Control-D
138 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
138 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
139 you can force a direct exit without any confirmation.""",
139 you can force a direct exit without any confirmation.""",
140 "Don't prompt the user when exiting."
140 "Don't prompt the user when exiting."
141 )
141 )
142 addflag('term-title', 'TerminalInteractiveShell.term_title',
142 addflag('term-title', 'TerminalInteractiveShell.term_title',
143 "Enable auto setting the terminal title.",
143 "Enable auto setting the terminal title.",
144 "Disable auto setting the terminal title."
144 "Disable auto setting the terminal title."
145 )
145 )
146 classic_config = Config()
146 classic_config = Config()
147 classic_config.InteractiveShell.cache_size = 0
147 classic_config.InteractiveShell.cache_size = 0
148 classic_config.PlainTextFormatter.pprint = False
148 classic_config.PlainTextFormatter.pprint = False
149 classic_config.PromptManager.in_template = '>>> '
149 classic_config.PromptManager.in_template = '>>> '
150 classic_config.PromptManager.in2_template = '... '
150 classic_config.PromptManager.in2_template = '... '
151 classic_config.PromptManager.out_template = ''
151 classic_config.PromptManager.out_template = ''
152 classic_config.InteractiveShell.separate_in = ''
152 classic_config.InteractiveShell.separate_in = ''
153 classic_config.InteractiveShell.separate_out = ''
153 classic_config.InteractiveShell.separate_out = ''
154 classic_config.InteractiveShell.separate_out2 = ''
154 classic_config.InteractiveShell.separate_out2 = ''
155 classic_config.InteractiveShell.colors = 'NoColor'
155 classic_config.InteractiveShell.colors = 'NoColor'
156 classic_config.InteractiveShell.xmode = 'Plain'
156 classic_config.InteractiveShell.xmode = 'Plain'
157
157
158 frontend_flags['classic']=(
158 frontend_flags['classic']=(
159 classic_config,
159 classic_config,
160 "Gives IPython a similar feel to the classic Python prompt."
160 "Gives IPython a similar feel to the classic Python prompt."
161 )
161 )
162 # # log doesn't make so much sense this way anymore
162 # # log doesn't make so much sense this way anymore
163 # paa('--log','-l',
163 # paa('--log','-l',
164 # action='store_true', dest='InteractiveShell.logstart',
164 # action='store_true', dest='InteractiveShell.logstart',
165 # help="Start logging to the default log file (./ipython_log.py).")
165 # help="Start logging to the default log file (./ipython_log.py).")
166 #
166 #
167 # # quick is harder to implement
167 # # quick is harder to implement
168 frontend_flags['quick']=(
168 frontend_flags['quick']=(
169 {'TerminalIPythonApp' : {'quick' : True}},
169 {'TerminalIPythonApp' : {'quick' : True}},
170 "Enable quick startup with no config files."
170 "Enable quick startup with no config files."
171 )
171 )
172
172
173 frontend_flags['i'] = (
173 frontend_flags['i'] = (
174 {'TerminalIPythonApp' : {'force_interact' : True}},
174 {'TerminalIPythonApp' : {'force_interact' : True}},
175 """If running code from the command line, become interactive afterwards.
175 """If running code from the command line, become interactive afterwards.
176 Note: can also be given simply as '-i.'"""
176 Note: can also be given simply as '-i.'"""
177 )
177 )
178 flags.update(frontend_flags)
178 flags.update(frontend_flags)
179
179
180 aliases = dict(base_aliases)
180 aliases = dict(base_aliases)
181 aliases.update(shell_aliases)
181 aliases.update(shell_aliases)
182
182
183 #-----------------------------------------------------------------------------
183 #-----------------------------------------------------------------------------
184 # Main classes and functions
184 # Main classes and functions
185 #-----------------------------------------------------------------------------
185 #-----------------------------------------------------------------------------
186
186
187
187
188 class LocateIPythonApp(BaseIPythonApplication):
188 class LocateIPythonApp(BaseIPythonApplication):
189 description = """print the path to the IPython dir"""
189 description = """print the path to the IPython dir"""
190 subcommands = Dict(dict(
190 subcommands = Dict(dict(
191 profile=('IPython.core.profileapp.ProfileLocate',
191 profile=('IPython.core.profileapp.ProfileLocate',
192 "print the path to an IPython profile directory",
192 "print the path to an IPython profile directory",
193 ),
193 ),
194 ))
194 ))
195 def start(self):
195 def start(self):
196 if self.subapp is not None:
196 if self.subapp is not None:
197 return self.subapp.start()
197 return self.subapp.start()
198 else:
198 else:
199 print self.ipython_dir
199 print self.ipython_dir
200
200
201
201
202 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
202 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
203 name = u'ipython'
203 name = u'ipython'
204 description = usage.cl_usage
204 description = usage.cl_usage
205 default_config_file_name = default_config_file_name
205 default_config_file_name = default_config_file_name
206 crash_handler_class = IPAppCrashHandler
206 crash_handler_class = IPAppCrashHandler
207 examples = _examples
207 examples = _examples
208
208
209 flags = Dict(flags)
209 flags = Dict(flags)
210 aliases = Dict(aliases)
210 aliases = Dict(aliases)
211 classes = List()
211 classes = List()
212 def _classes_default(self):
212 def _classes_default(self):
213 """This has to be in a method, for TerminalIPythonApp to be available."""
213 """This has to be in a method, for TerminalIPythonApp to be available."""
214 return [
214 return [
215 InteractiveShellApp, # ShellApp comes before TerminalApp, because
215 InteractiveShellApp, # ShellApp comes before TerminalApp, because
216 self.__class__, # it will also affect subclasses (e.g. QtConsole)
216 self.__class__, # it will also affect subclasses (e.g. QtConsole)
217 TerminalInteractiveShell,
217 TerminalInteractiveShell,
218 PromptManager,
218 PromptManager,
219 HistoryManager,
219 HistoryManager,
220 ProfileDir,
220 ProfileDir,
221 PlainTextFormatter,
221 PlainTextFormatter,
222 IPCompleter,
222 IPCompleter,
223 ScriptMagics,
223 ScriptMagics,
224 ]
224 ]
225
225
226 subcommands = Dict(dict(
226 subcommands = Dict(dict(
227 qtconsole=('IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp',
227 qtconsole=('IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp',
228 """Launch the IPython Qt Console."""
228 """Launch the IPython Qt Console."""
229 ),
229 ),
230 notebook=('IPython.frontend.html.notebook.notebookapp.NotebookApp',
230 notebook=('IPython.frontend.html.notebook.notebookapp.NotebookApp',
231 """Launch the IPython HTML Notebook Server."""
231 """Launch the IPython HTML Notebook Server."""
232 ),
232 ),
233 profile = ("IPython.core.profileapp.ProfileApp",
233 profile = ("IPython.core.profileapp.ProfileApp",
234 "Create and manage IPython profiles."
234 "Create and manage IPython profiles."
235 ),
235 ),
236 kernel = ("IPython.zmq.ipkernel.IPKernelApp",
236 kernel = ("IPython.zmq.ipkernel.IPKernelApp",
237 "Start a kernel without an attached frontend."
237 "Start a kernel without an attached frontend."
238 ),
238 ),
239 console=('IPython.frontend.terminal.console.app.ZMQTerminalIPythonApp',
239 console=('IPython.frontend.terminal.console.app.ZMQTerminalIPythonApp',
240 """Launch the IPython terminal-based Console."""
240 """Launch the IPython terminal-based Console."""
241 ),
241 ),
242 locate=('IPython.frontend.terminal.ipapp.LocateIPythonApp',
242 locate=('IPython.frontend.terminal.ipapp.LocateIPythonApp',
243 LocateIPythonApp.description
243 LocateIPythonApp.description
244 ),
244 ),
245 ))
245 ))
246
246
247 # *do* autocreate requested profile, but don't create the config file.
247 # *do* autocreate requested profile, but don't create the config file.
248 auto_create=Bool(True)
248 auto_create=Bool(True)
249 # configurables
249 # configurables
250 ignore_old_config=Bool(False, config=True,
250 ignore_old_config=Bool(False, config=True,
251 help="Suppress warning messages about legacy config files"
251 help="Suppress warning messages about legacy config files"
252 )
252 )
253 quick = Bool(False, config=True,
253 quick = Bool(False, config=True,
254 help="""Start IPython quickly by skipping the loading of config files."""
254 help="""Start IPython quickly by skipping the loading of config files."""
255 )
255 )
256 def _quick_changed(self, name, old, new):
256 def _quick_changed(self, name, old, new):
257 if new:
257 if new:
258 self.load_config_file = lambda *a, **kw: None
258 self.load_config_file = lambda *a, **kw: None
259 self.ignore_old_config=True
259 self.ignore_old_config=True
260
260
261 display_banner = Bool(True, config=True,
261 display_banner = Bool(True, config=True,
262 help="Whether to display a banner upon starting IPython."
262 help="Whether to display a banner upon starting IPython."
263 )
263 )
264
264
265 # if there is code of files to run from the cmd line, don't interact
265 # if there is code of files to run from the cmd line, don't interact
266 # unless the --i flag (App.force_interact) is true.
266 # unless the --i flag (App.force_interact) is true.
267 force_interact = Bool(False, config=True,
267 force_interact = Bool(False, config=True,
268 help="""If a command or file is given via the command-line,
268 help="""If a command or file is given via the command-line,
269 e.g. 'ipython foo.py"""
269 e.g. 'ipython foo.py"""
270 )
270 )
271 def _force_interact_changed(self, name, old, new):
271 def _force_interact_changed(self, name, old, new):
272 if new:
272 if new:
273 self.interact = True
273 self.interact = True
274
274
275 def _file_to_run_changed(self, name, old, new):
275 def _file_to_run_changed(self, name, old, new):
276 if new:
276 if new:
277 self.something_to_run = True
277 self.something_to_run = True
278 if new and not self.force_interact:
278 if new and not self.force_interact:
279 self.interact = False
279 self.interact = False
280 _code_to_run_changed = _file_to_run_changed
280 _code_to_run_changed = _file_to_run_changed
281 _module_to_run_changed = _file_to_run_changed
281 _module_to_run_changed = _file_to_run_changed
282
282
283 # internal, not-configurable
283 # internal, not-configurable
284 interact=Bool(True)
284 interact=Bool(True)
285 something_to_run=Bool(False)
285 something_to_run=Bool(False)
286
286
287 def parse_command_line(self, argv=None):
287 def parse_command_line(self, argv=None):
288 """override to allow old '-pylab' flag with deprecation warning"""
288 """override to allow old '-pylab' flag with deprecation warning"""
289
289
290 argv = sys.argv[1:] if argv is None else argv
290 argv = sys.argv[1:] if argv is None else argv
291
291
292 if '-pylab' in argv:
292 if '-pylab' in argv:
293 # deprecated `-pylab` given,
293 # deprecated `-pylab` given,
294 # warn and transform into current syntax
294 # warn and transform into current syntax
295 argv = argv[:] # copy, don't clobber
295 argv = argv[:] # copy, don't clobber
296 idx = argv.index('-pylab')
296 idx = argv.index('-pylab')
297 warn.warn("`-pylab` flag has been deprecated.\n"
297 warn.warn("`-pylab` flag has been deprecated.\n"
298 " Use `--pylab` instead, or `--pylab=foo` to specify a backend.")
298 " Use `--pylab` instead, or `--pylab=foo` to specify a backend.")
299 sub = '--pylab'
299 sub = '--pylab'
300 if len(argv) > idx+1:
300 if len(argv) > idx+1:
301 # check for gui arg, as in '-pylab qt'
301 # check for gui arg, as in '-pylab qt'
302 gui = argv[idx+1]
302 gui = argv[idx+1]
303 if gui in ('wx', 'qt', 'qt4', 'gtk', 'auto'):
303 if gui in ('wx', 'qt', 'qt4', 'gtk', 'auto'):
304 sub = '--pylab='+gui
304 sub = '--pylab='+gui
305 argv.pop(idx+1)
305 argv.pop(idx+1)
306 argv[idx] = sub
306 argv[idx] = sub
307
307
308 return super(TerminalIPythonApp, self).parse_command_line(argv)
308 return super(TerminalIPythonApp, self).parse_command_line(argv)
309
309
310 @catch_config_error
310 @catch_config_error
311 def initialize(self, argv=None):
311 def initialize(self, argv=None):
312 """Do actions after construct, but before starting the app."""
312 """Do actions after construct, but before starting the app."""
313 super(TerminalIPythonApp, self).initialize(argv)
313 super(TerminalIPythonApp, self).initialize(argv)
314 if self.subapp is not None:
314 if self.subapp is not None:
315 # don't bother initializing further, starting subapp
315 # don't bother initializing further, starting subapp
316 return
316 return
317 if not self.ignore_old_config:
317 if not self.ignore_old_config:
318 check_for_old_config(self.ipython_dir)
318 check_for_old_config(self.ipython_dir)
319 # print self.extra_args
319 # print self.extra_args
320 if self.extra_args and not self.something_to_run:
320 if self.extra_args and not self.something_to_run:
321 self.file_to_run = self.extra_args[0]
321 self.file_to_run = self.extra_args[0]
322 self.init_path()
322 self.init_path()
323 # create the shell
323 # create the shell
324 self.init_shell()
324 self.init_shell()
325 # and draw the banner
325 # and draw the banner
326 self.init_banner()
326 self.init_banner()
327 # Now a variety of things that happen after the banner is printed.
327 # Now a variety of things that happen after the banner is printed.
328 self.init_gui_pylab()
328 self.init_gui_pylab()
329 self.init_extensions()
329 self.init_extensions()
330 self.init_code()
330 self.init_code()
331
331
332 def init_shell(self):
332 def init_shell(self):
333 """initialize the InteractiveShell instance"""
333 """initialize the InteractiveShell instance"""
334 # Create an InteractiveShell instance.
334 # Create an InteractiveShell instance.
335 # shell.display_banner should always be False for the terminal
335 # shell.display_banner should always be False for the terminal
336 # based app, because we call shell.show_banner() by hand below
336 # based app, because we call shell.show_banner() by hand below
337 # so the banner shows *before* all extension loading stuff.
337 # so the banner shows *before* all extension loading stuff.
338 self.shell = TerminalInteractiveShell.instance(config=self.config,
338 self.shell = TerminalInteractiveShell.instance(config=self.config,
339 display_banner=False, profile_dir=self.profile_dir,
339 display_banner=False, profile_dir=self.profile_dir,
340 ipython_dir=self.ipython_dir)
340 ipython_dir=self.ipython_dir)
341 self.shell.configurables.append(self)
341 self.shell.configurables.append(self)
342
342
343 def init_banner(self):
343 def init_banner(self):
344 """optionally display the banner"""
344 """optionally display the banner"""
345 if self.display_banner and self.interact:
345 if self.display_banner and self.interact:
346 self.shell.show_banner()
346 self.shell.show_banner()
347 # Make sure there is a space below the banner.
347 # Make sure there is a space below the banner.
348 if self.log_level <= logging.INFO: print
348 if self.log_level <= logging.INFO: print
349
349
350 def _pylab_changed(self, name, old, new):
350 def _pylab_changed(self, name, old, new):
351 """Replace --pylab='inline' with --pylab='auto'"""
351 """Replace --pylab='inline' with --pylab='auto'"""
352 if new == 'inline':
352 if new == 'inline':
353 warn.warn("'inline' not available as pylab backend, "
353 warn.warn("'inline' not available as pylab backend, "
354 "using 'auto' instead.")
354 "using 'auto' instead.")
355 self.pylab = 'auto'
355 self.pylab = 'auto'
356
356
357 def start(self):
357 def start(self):
358 if self.subapp is not None:
358 if self.subapp is not None:
359 return self.subapp.start()
359 return self.subapp.start()
360 # perform any prexec steps:
360 # perform any prexec steps:
361 if self.interact:
361 if self.interact:
362 self.log.debug("Starting IPython's mainloop...")
362 self.log.debug("Starting IPython's mainloop...")
363 self.shell.mainloop()
363 self.shell.mainloop()
364 else:
364 else:
365 self.log.debug("IPython not interactive...")
365 self.log.debug("IPython not interactive...")
366
366
367
367
368 def load_default_config(ipython_dir=None):
368 def load_default_config(ipython_dir=None):
369 """Load the default config file from the default ipython_dir.
369 """Load the default config file from the default ipython_dir.
370
370
371 This is useful for embedded shells.
371 This is useful for embedded shells.
372 """
372 """
373 if ipython_dir is None:
373 if ipython_dir is None:
374 ipython_dir = get_ipython_dir()
374 ipython_dir = get_ipython_dir()
375 profile_dir = os.path.join(ipython_dir, 'profile_default')
375 profile_dir = os.path.join(ipython_dir, 'profile_default')
376 cl = PyFileConfigLoader(default_config_file_name, profile_dir)
376 cl = PyFileConfigLoader(default_config_file_name, profile_dir)
377 try:
377 try:
378 config = cl.load_config()
378 config = cl.load_config()
379 except ConfigFileNotFound:
379 except ConfigFileNotFound:
380 # no config found
380 # no config found
381 config = Config()
381 config = Config()
382 return config
382 return config
383
383
384
384
385 def launch_new_instance():
385 def launch_new_instance():
386 """Create and run a full blown IPython instance"""
386 """Create and run a full blown IPython instance"""
387 app = TerminalIPythonApp.instance()
387 app = TerminalIPythonApp.instance()
388 app.initialize()
388 app.initialize()
389 app.start()
389 app.start()
390
390
391
391
392 if __name__ == '__main__':
392 if __name__ == '__main__':
393 launch_new_instance()
393 launch_new_instance()
General Comments 0
You need to be logged in to leave comments. Login now