#----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- flags = dict(ipkernel_flags) qt_flags = { 'existing' : ({'IPythonQtConsoleApp' : {'existing' : 'kernel*.json'}}, "Connect to an existing kernel. If no argument specified, guess most recent"), 'pure' : ({'IPythonQtConsoleApp' : {'pure' : True}}, "Use a pure Python kernel instead of an IPython kernel."), 'plain' : ({'ConsoleWidget' : {'kind' : 'plain'}}, "Disable rich text support."), } qt_flags.update(boolean_flag( 'gui-completion', 'ConsoleWidget.gui_completion', "use a GUI widget for tab completion", "use plaintext output for completion" )) qt_flags.update(boolean_flag( 'confirm-exit', 'IPythonQtConsoleApp.confirm_exit', """Set to display confirmation dialog on exit. You can always use 'exit' or 'quit', to force a direct exit without any confirmation. """, """Don't prompt the user when exiting. This will terminate the kernel if it is owned by the frontend, and leave it alive if it is external. """ )) flags.update(qt_flags) aliases = dict(ipkernel_aliases)
#----------------------------------------------------------------------------- flags = dict(kernel_flags) # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, # or it will raise an error on unrecognized flags app_flags = { 'existing' : ({'IPythonConsoleApp' : {'existing' : 'kernel*.json'}}, "Connect to an existing kernel. If no argument specified, guess most recent"), } app_flags.update(boolean_flag( 'confirm-exit', 'IPythonConsoleApp.confirm_exit', """Set to display confirmation dialog on exit. You can always use 'exit' or 'quit', to force a direct exit without any confirmation. """, """Don't prompt the user when exiting. This will terminate the kernel if it is owned by the frontend, and leave it alive if it is external. """ )) flags.update(app_flags) aliases = dict(kernel_aliases) # also scrub aliases from the frontend app_aliases = dict( ip = 'IPythonConsoleApp.ip', transport = 'IPythonConsoleApp.transport', hb = 'IPythonConsoleApp.hb_port', shell = 'IPythonConsoleApp.shell_port', iopub = 'IPythonConsoleApp.iopub_port',
flags['read-only'] = ( {'NotebookApp' : {'read_only' : True}}, """Allow read-only access to notebooks. When using a password to protect the notebook server, this flag allows unauthenticated clients to view the notebook list, and individual notebooks, but not edit them, start kernels, or run code. If no password is set, the server will be entirely read-only. """ ) # Add notebook manager flags flags.update(boolean_flag('script', 'FileNotebookManager.save_script', 'Auto-save a .py script everytime the .ipynb notebook is saved', 'Do not auto-save .py scripts for every notebook')) # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, # or it will raise an error on unrecognized flags notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script', 'no-script'] aliases = dict(kernel_aliases) aliases.update({ 'ip': 'NotebookApp.ip', 'port': 'NotebookApp.port', 'port-retries': 'NotebookApp.port_retries', 'transport': 'KernelManager.transport', 'keyfile': 'NotebookApp.keyfile',
""" # ----------------------------------------------------------------------------- # Aliases and Flags # ----------------------------------------------------------------------------- # start with copy of flags flags = dict(flags) qt_flags = { "pure": ({"IPythonQtConsoleApp": {"pure": True}}, "Use a pure Python kernel instead of an IPython kernel."), "plain": ({"ConsoleWidget": {"kind": "plain"}}, "Disable rich text support."), } qt_flags.update( boolean_flag( "gui-completion", "ConsoleWidget.gui_completion", "use a GUI widget for tab completion", "use plaintext output for completion", ) ) # and app_flags from the Console Mixin qt_flags.update(app_flags) # add frontend flags to the full set flags.update(qt_flags) # start with copy of front&backend aliases list aliases = dict(aliases) qt_aliases = dict( style="IPythonWidget.syntax_style", stylesheet="IPythonQtConsoleApp.stylesheet", colors="ZMQInteractiveShell.colors", editor="IPythonWidget.editor",
flags['read-only'] = ( {'NotebookApp' : {'read_only' : True}}, """Allow read-only access to notebooks. When using a password to protect the notebook server, this flag allows unauthenticated clients to view the notebook list, and individual notebooks, but not edit them, start kernels, or run code. If no password is set, the server will be entirely read-only. """ ) # Add notebook manager flags flags.update(boolean_flag('script', 'NotebookManager.save_script', 'Auto-save a .py script everytime the .ipynb notebook is saved', 'Do not auto-save .py scripts for every notebook')) # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, # or it will raise an error on unrecognized flags notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script', 'no-script'] aliases = dict(ipkernel_aliases) aliases.update({ 'ip': 'NotebookApp.ip', 'port': 'NotebookApp.port', 'keyfile': 'NotebookApp.keyfile', 'certfile': 'NotebookApp.certfile', 'notebook-dir': 'NotebookManager.notebook_dir',
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) #----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- flags = dict(base_flags) flags.update(shell_flags) frontend_flags = {} addflag = lambda *args: frontend_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.' ) addflag('banner', 'TerminalIPythonApp.display_banner', "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 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit', you can force a direct exit without any confirmation.""", "Don't prompt the user when exiting." ) addflag('term-title', 'TerminalInteractiveShell.term_title',
ipython qtconsole --matplotlib=inline # start with matplotlib inline plotting mode """ #----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- # start with copy of flags flags = dict(flags) qt_flags = { 'plain' : ({'IPythonQtConsoleApp' : {'plain' : True}}, "Disable rich text support."), } qt_flags.update(boolean_flag( 'banner', 'IPythonQtConsoleApp.display_banner', "Display a banner upon starting the QtConsole.", "Don't display a banner upon starting the QtConsole." )) # and app_flags from the Console Mixin qt_flags.update(app_flags) # add frontend flags to the full set flags.update(qt_flags) # start with copy of front&backend aliases list aliases = dict(aliases) qt_aliases = dict( style = 'IPythonWidget.syntax_style', stylesheet = 'IPythonQtConsoleApp.stylesheet', colors = 'ZMQInteractiveShell.colors',
flags = dict(flags) qt_flags = { 'pure': ({ 'IPythonQtConsoleApp': { 'pure': True } }, "Use a pure Python kernel instead of an IPython kernel."), 'plain': ({ 'ConsoleWidget': { 'kind': 'plain' } }, "Disable rich text support."), } qt_flags.update( boolean_flag('gui-completion', 'ConsoleWidget.gui_completion', "use a GUI widget for tab completion", "use plaintext output for completion")) # and app_flags from the Console Mixin qt_flags.update(app_flags) # add frontend flags to the full set flags.update(qt_flags) # start with copy of front&backend aliases list aliases = dict(aliases) qt_aliases = dict( style='IPythonWidget.syntax_style', stylesheet='IPythonQtConsoleApp.stylesheet', colors='ZMQInteractiveShell.colors', editor='IPythonWidget.editor', paging='ConsoleWidget.paging', )
}, 'use the MongoDB backend'), 'dictdb': ({ 'HubFactory': { 'db_class': 'IPython.parallel.controller.dictdb.DictDB' } }, 'use the in-memory DictDB backend'), 'reuse': ({ 'IPControllerApp': { 'reuse_files': True } }, 'reuse existing json connection files') }) flags.update( boolean_flag('secure', 'IPControllerApp.secure', "Use HMAC digests for authentication of messages.", "Don't authenticate messages.")) aliases = dict( reuse_files='IPControllerApp.reuse_files', secure='IPControllerApp.secure', ssh='IPControllerApp.ssh_server', use_threads='IPControllerApp.use_threads', location='IPControllerApp.location', ident='Session.session', user='******', exec_key='Session.keyfile', url='HubFactory.url', ip='HubFactory.ip', transport='HubFactory.transport', port='HubFactory.regport', ping='HeartMonitor.period',
for path in paths: files = os.listdir(path) for f in files: full_path = os.path.join(path, f) if os.path.isdir(full_path) and f.startswith('profile_'): profile = f.split('_',1)[-1] start_cmd = 'ipython profile=%s' % profile print start_cmd + " ==> " + full_path def start(self): self.list_profile_dirs() create_flags = {} create_flags.update(base_flags) create_flags.update(boolean_flag('reset', 'ProfileCreate.overwrite', "reset config files to defaults", "leave existing config files")) create_flags.update(boolean_flag('parallel', 'ProfileCreate.parallel', "Include parallel computing config files", "Don't include parallel computing config files")) class ProfileCreate(BaseIPythonApplication): name = u'ipython-profile' description = create_help auto_create = Bool(True, config=False) def _copy_config_files_default(self): return True parallel = Bool(False, config=True, help="whether to include parallel computing config files") def _parallel_changed(self, name, old, new):
'NotebookApp': { 'enable_mathjax': False } }, """Disable MathJax MathJax is the javascript library IPython uses to render math/LaTeX. It is very large, so you may want to disable it if you have a slow internet connection, or for offline use of the notebook. When disabled, equations etc. will appear as their untransformed TeX source. """) # Add notebook manager flags flags.update( boolean_flag( 'script', 'FileNotebookManager.save_script', 'Auto-save a .py script everytime the .ipynb notebook is saved', 'Do not auto-save .py scripts for every notebook')) flags.update( boolean_flag( 'clean', 'FileNotebookManager.save_clean', 'Save a ".clean" (no output) version when the notebook is saved.', 'Do auto-save a ".clean" (no output) version')) # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, # or it will raise an error on unrecognized flags notebook_flags = [ 'no-browser', 'no-mathjax', 'script', 'no-script', 'clean', 'no-clean' ]
"Connect to an existing kernel. If no argument specified, guess most recent" ), 'pure': ({ 'IPythonQtConsoleApp': { 'pure': True } }, "Use a pure Python kernel instead of an IPython kernel."), 'plain': ({ 'ConsoleWidget': { 'kind': 'plain' } }, "Disable rich text support."), } qt_flags.update( boolean_flag('gui-completion', 'ConsoleWidget.gui_completion', "use a GUI widget for tab completion", "use plaintext output for completion")) qt_flags.update( boolean_flag( 'confirm-exit', 'IPythonQtConsoleApp.confirm_exit', """Set to display confirmation dialog on exit. You can always use 'exit' or 'quit', to force a direct exit without any confirmation. """, """Don't prompt the user when exiting. This will terminate the kernel if it is owned by the frontend, and leave it alive if it is external. """)) flags.update(qt_flags) aliases = dict(ipkernel_aliases) qt_aliases = dict( hb='IPythonQtConsoleApp.hb_port',
full_path = os.path.join(path, f) if os.path.isdir(full_path) and f.startswith('profile_') and \ os.path.isfile(os.path.join(full_path, 'ipcontroller_config.py')): profile = f.split('_')[-1] start_cmd = 'ipcluster start profile=%s n=4' % profile print start_cmd + " ==> " + full_path def start(self): self.list_profile_dirs() # `ipcluster create` will be deprecated when `ipython profile create` or equivalent exists create_flags = {} create_flags.update(base_flags) create_flags.update(boolean_flag('reset', 'IPClusterCreate.overwrite', "reset config files to defaults", "leave existing config files")) class IPClusterCreate(BaseParallelApplication): name = u'ipcluster-create' description = create_help auto_create = Bool(True) config_file_name = Unicode(default_config_file_name) flags = Dict(create_flags) aliases = Dict(dict(profile='BaseIPythonApplication.profile')) classes = [ProfileDir] stop_aliases = dict(
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) #----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- flags = dict(base_flags) flags.update(shell_flags) frontend_flags = {} addflag = lambda *args: frontend_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.') addflag('banner', 'TerminalIPythonApp.display_banner', "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 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit', you can force a direct exit without any confirmation.""", "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.")
"""Allow read-only access to notebooks. When using a password to protect the notebook server, this flag allows unauthenticated clients to view the notebook list, and individual notebooks, but not edit them, start kernels, or run code. If no password is set, the server will be entirely read-only. """, ) # Add notebook manager flags flags.update( boolean_flag( "script", "NotebookManager.save_script", "Auto-save a .py script everytime the .ipynb notebook is saved", "Do not auto-save .py scripts for every notebook", ) ) # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, # or it will raise an error on unrecognized flags notebook_flags = ["no-browser", "no-mathjax", "read-only", "script", "no-script"] aliases = dict(ipkernel_aliases) aliases.update( { "ip": "NotebookApp.ip", "port": "NotebookApp.port",
#----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- # start with copy of flags flags = dict(flags) qt_flags = { 'pure' : ({'IPythonQtConsoleApp' : {'pure' : True}}, "Use a pure Python kernel instead of an IPython kernel."), 'plain' : ({'ConsoleWidget' : {'kind' : 'plain'}}, "Disable rich text support."), } qt_flags.update(boolean_flag( 'gui-completion', 'ConsoleWidget.gui_completion', "use a GUI widget for tab completion", "use plaintext output for completion" )) # and app_flags from the Console Mixin qt_flags.update(app_flags) # add frontend flags to the full set flags.update(qt_flags) # start with copy of front&backend aliases list aliases = dict(aliases) qt_aliases = dict( style = 'IPythonWidget.syntax_style', stylesheet = 'IPythonQtConsoleApp.stylesheet', colors = 'ZMQInteractiveShell.colors',
"DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.", ) flags["no-mathjax"] = ( {"NotebookApp": {"enable_mathjax": False}}, """Disable MathJax MathJax is the javascript library IPython uses to render math/LaTeX. It is very large, so you may want to disable it if you have a slow internet connection, or for offline use of the notebook. When disabled, equations etc. will appear as their untransformed TeX source. """, ) # Add notebook manager flags flags.update(boolean_flag("script", "FileContentsManager.save_script", "DEPRECATED, IGNORED", "DEPRECATED, IGNORED")) aliases = dict(base_aliases) aliases.update( { "ip": "NotebookApp.ip", "port": "NotebookApp.port", "port-retries": "NotebookApp.port_retries", "transport": "KernelManager.transport", "keyfile": "NotebookApp.keyfile", "certfile": "NotebookApp.certfile", "notebook-dir": "NotebookApp.notebook_dir", "browser": "NotebookApp.browser", "pylab": "NotebookApp.pylab", }
from IPython.config.configurable import Configurable from IPython.config.loader import Config from IPython.core import pylabtools from IPython.utils import py3compat from IPython.utils.path import filefind from IPython.utils.traitlets import ( Unicode, Instance, List, Bool, CaselessStrEnum ) #----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- shell_flags = {} addflag = lambda *args: shell_flags.update(boolean_flag(*args)) addflag('autoindent', 'InteractiveShell.autoindent', 'Turn on autoindenting.', 'Turn off autoindenting.' ) addflag('automagic', 'InteractiveShell.automagic', """Turn on the auto calling of magic commands. Type %%magic at the IPython prompt for more information.""", 'Turn off the auto calling of magic commands.' ) addflag('pdb', 'InteractiveShell.pdb', "Enable auto calling the pdb debugger after every exception.", "Disable auto calling the pdb debugger after every exception." ) # pydb flag doesn't do any config, as core.debugger switches on import, # which is before parsing. This just allows the flag to be passed. shell_flags.update(dict(
from IPython.config.application import boolean_flag from IPython.config.configurable import Configurable from IPython.config.loader import Config from IPython.core import pylabtools from IPython.utils import py3compat from IPython.utils.path import filefind from IPython.utils.traitlets import (Unicode, Instance, List, Bool, CaselessStrEnum) #----------------------------------------------------------------------------- # Aliases and Flags #----------------------------------------------------------------------------- shell_flags = {} addflag = lambda *args: shell_flags.update(boolean_flag(*args)) addflag('autoindent', 'InteractiveShell.autoindent', 'Turn on autoindenting.', 'Turn off autoindenting.') addflag( 'automagic', 'InteractiveShell.automagic', """Turn on the auto calling of magic commands. Type %%magic at the IPython prompt for more information.""", 'Turn off the auto calling of magic commands.') addflag('pdb', 'InteractiveShell.pdb', "Enable auto calling the pdb debugger after every exception.", "Disable auto calling the pdb debugger after every exception.") # pydb flag doesn't do any config, as core.debugger switches on import, # which is before parsing. This just allows the flag to be passed. shell_flags.update( dict(pydb=( {}, """Use the third party 'pydb' package as debugger, instead of pdb.
flags.update(base_flags) flags.update({ 'usethreads' : ( {'IPControllerApp' : {'use_threads' : True}}, 'Use threads instead of processes for the schedulers'), 'sqlitedb' : ({'HubFactory' : {'db_class' : 'IPython.parallel.controller.sqlitedb.SQLiteDB'}}, 'use the SQLiteDB backend'), 'mongodb' : ({'HubFactory' : {'db_class' : 'IPython.parallel.controller.mongodb.MongoDB'}}, 'use the MongoDB backend'), 'dictdb' : ({'HubFactory' : {'db_class' : 'IPython.parallel.controller.dictdb.DictDB'}}, 'use the in-memory DictDB backend'), 'reuse' : ({'IPControllerApp' : {'reuse_files' : True}}, 'reuse existing json connection files') }) flags.update(boolean_flag('secure', 'IPControllerApp.secure', "Use HMAC digests for authentication of messages.", "Don't authenticate messages." )) aliases = dict( secure = 'IPControllerApp.secure', ssh = 'IPControllerApp.ssh_server', location = 'IPControllerApp.location', ident = 'Session.session', user = '******', keyfile = 'Session.keyfile', url = 'HubFactory.url', ip = 'HubFactory.ip', transport = 'HubFactory.transport', port = 'HubFactory.regport',
) flags['no-mathjax']=( {'NotebookApp' : {'enable_mathjax' : False}}, """Disable MathJax MathJax is the javascript library IPython uses to render math/LaTeX. It is very large, so you may want to disable it if you have a slow internet connection, or for offline use of the notebook. When disabled, equations etc. will appear as their untransformed TeX source. """ ) # Add notebook manager flags flags.update(boolean_flag('script', 'FileContentsManager.save_script', 'DEPRECATED, IGNORED', 'DEPRECATED, IGNORED')) aliases = dict(base_aliases) aliases.update({ 'ip': 'NotebookApp.ip', 'port': 'NotebookApp.port', 'port-retries': 'NotebookApp.port_retries', 'transport': 'KernelManager.transport', 'keyfile': 'NotebookApp.keyfile', 'certfile': 'NotebookApp.certfile', 'notebook-dir': 'NotebookApp.notebook_dir', 'browser': 'NotebookApp.browser', 'pylab': 'NotebookApp.pylab', })
_examples = """ ipython qtconsole # start the qtconsole ipython qtconsole --matplotlib=inline # start with matplotlib inline plotting mode """ # ----------------------------------------------------------------------------- # Aliases and Flags # ----------------------------------------------------------------------------- # start with copy of flags flags = dict(flags) qt_flags = {"plain": ({"IPythonQtConsoleApp": {"plain": True}}, "Disable rich text support.")} qt_flags.update( boolean_flag( "banner", "IPythonQtConsoleApp.display_banner", "Display a banner upon starting the QtConsole.", "Don't display a banner upon starting the QtConsole.", ) ) # and app_flags from the Console Mixin qt_flags.update(app_flags) # add frontend flags to the full set flags.update(qt_flags) # start with copy of front&backend aliases list aliases = dict(aliases) qt_aliases = dict( style="IPythonWidget.syntax_style", stylesheet="IPythonQtConsoleApp.stylesheet", colors="ZMQInteractiveShell.colors",