Skip to content

Commit

Permalink
Merge pull request #9042 from Carreau/deprecate-subcommands
Browse files Browse the repository at this point in the history
Actually warn that `ipython <subcommand>` is deprecated.
  • Loading branch information
minrk committed Dec 7, 2015
2 parents 1d77f90 + 51ca6ff commit 4bfe6b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
15 changes: 14 additions & 1 deletion IPython/core/application.py
Expand Up @@ -185,7 +185,7 @@ def __init__(self, **kwargs):
super(BaseIPythonApplication, self).__init__(**kwargs)
# ensure current working directory exists
try:
directory = py3compat.getcwd()
py3compat.getcwd()
except:
# exit if cwd doesn't exist
self.log.error("Current working directory doesn't exist.")
Expand All @@ -195,6 +195,19 @@ def __init__(self, **kwargs):
# Various stages of Application creation
#-------------------------------------------------------------------------

def initialize_subcommand(self, subc, argv=None):
if subc in self.deprecated_subcommands:
import time
self.log.warning("Subcommand `ipython {sub}` is deprecated and will be removed "
"in future versions.".format(sub=subc))
self.log.warning("You likely want to use `jupyter {sub}`... continue "
"in 5 sec. Press Ctrl-C to quit now.".format(sub=subc))
try:
time.sleep(5)
except KeyboardInterrupt:
sys.exit(1)
return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)

def init_crash_handler(self):
"""Create a crash handler, typically setting sys.excepthook to it."""
self.crash_handler = self.crash_handler_class(self)
Expand Down
42 changes: 17 additions & 25 deletions IPython/terminal/ipapp.py
Expand Up @@ -50,22 +50,11 @@
ipython --log-level=DEBUG # set logging to DEBUG
ipython --profile=foo # start with profile foo
ipython qtconsole # start the qtconsole GUI application
ipython help qtconsole # show the help for the qtconsole subcmd
ipython console # start the terminal-based console application
ipython help console # show the help for the console subcmd
ipython notebook # start the IPython notebook
ipython help notebook # show the help for the notebook subcmd
ipython profile create foo # create profile foo w/ default config files
ipython help profile # show the help for the profile subcmd
ipython locate # print the path to the IPython directory
ipython locate profile foo # print the path to the directory for profile `foo`
ipython nbconvert # convert notebooks to/from other formats
"""

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -209,28 +198,16 @@ def _classes_default(self):
StoreMagics,
]

subcommands = dict(
deprecated_subcommands = dict(
qtconsole=('qtconsole.qtconsoleapp.JupyterQtConsoleApp',
"""DEPRECATD: Launch the Jupyter Qt Console."""
),
notebook=('notebook.notebookapp.NotebookApp',
"""DEPRECATED: Launch the Jupyter HTML Notebook Server."""
),
profile = ("IPython.core.profileapp.ProfileApp",
"Create and manage IPython profiles."
),
kernel = ("ipykernel.kernelapp.IPKernelApp",
"Start a kernel without an attached frontend."
),
console=('jupyter_console.app.ZMQTerminalIPythonApp',
"""DEPRECATED: Launch the Jupyter terminal-based Console."""
),
locate=('IPython.terminal.ipapp.LocateIPythonApp',
LocateIPythonApp.description
),
history=('IPython.core.historyapp.HistoryApp',
"Manage the IPython history database."
),
nbconvert=('nbconvert.nbconvertapp.NbConvertApp',
"DEPRECATED: Convert notebooks to/from other formats."
),
Expand All @@ -241,10 +218,25 @@ def _classes_default(self):
"DEPRECATED: Manage Jupyter kernel specifications."
),
)
subcommands['install-nbextension'] = (
subcommands = dict(
profile = ("IPython.core.profileapp.ProfileApp",
"Create and manage IPython profiles."
),
kernel = ("ipykernel.kernelapp.IPKernelApp",
"Start a kernel without an attached frontend."
),
locate=('IPython.terminal.ipapp.LocateIPythonApp',
LocateIPythonApp.description
),
history=('IPython.core.historyapp.HistoryApp',
"Manage the IPython history database."
),
)
deprecated_subcommands['install-nbextension'] = (
"notebook.nbextensions.InstallNBExtensionApp",
"DEPRECATED: Install Jupyter notebook extension files"
)
subcommands.update(deprecated_subcommands)

# *do* autocreate requested profile, but don't create the config file.
auto_create=Bool(True)
Expand Down

0 comments on commit 4bfe6b7

Please sign in to comment.