docs/narr/commandline.rst | ●●●●● patch | view | raw | blame | history | |
pyramid/paster.py | ●●●●● patch | view | raw | blame | history | |
pyramid/tests/test_paster.py | ●●●●● patch | view | raw | blame | history |
docs/narr/commandline.rst
@@ -269,37 +269,23 @@ .. index:: single: IPython single: bpython IPython ~~~~~~~ IPython or bpython ~~~~~~~~~~~~~~~~~~ If you have `IPython <http://en.wikipedia.org/wiki/IPython>`_ installed in the interpreter you use to invoke the ``paster`` command, the ``pshell`` command will use an IPython interactive shell instead of a standard Python interpreter shell. If you don't want this to happen, even if you have IPython installed, you can pass the ``--disable-ipython`` flag to the ``pshell`` command to use a standard Python interpreter shell unconditionally. If you have `IPython <http://en.wikipedia.org/wiki/IPython>`_ or `bpython <http://bpython-interpreter.org/>`_ or both installed in the interpreter you use to invoke the ``pshell`` command, ``pshell`` will autodiscover them and use the first respectively found in this order : IPython, bpython, standard Python interpreter. However you could specifically invoke one of your choice with the ``-p choice`` or ``--python-shell choice`` option. .. code-block:: text [chrism@vitaminf shellenv]$ ../bin/paster pshell --disable-ipython \ [chrism@vitaminf shellenv]$ ../bin/pshell -p ipython | bpython | python \ development.ini#MyProject bpython ~~~~~~~ If you have `bpython <http://bpython-interpreter.org/>`_ installed in the interpreter you use to invoke the ``pshell`` command, ``pshell`` will use a bpython interactive shell instead of a standard Python if you pass the ``-b`` or ``--enable-bpython`` flag to the ``pshell`` command. .. code-block:: text [chrism@vitaminf shellenv]$ ../bin/paster pshell --enable-bpython \ development.ini#MyProject .. index:: pyramid/paster.py
@@ -127,14 +127,9 @@ max_args = 1 parser = Command.standard_parser(simulate=True) parser.add_option('-d', '--disable-ipython', action='store_true', dest='disable_ipython', help="Don't use IPython even if it is available") parser.add_option('-b', '--enable-bpython', action='store_true', dest='enable_bpython', help="Use bpython as pshell") parser.add_option('-p', '--python-shell', action='store', type='string', dest='python_shell', default = '', help='ipython | bpython | python') parser.add_option('--setup', dest='setup', help=("A callable that will be passed the environment " @@ -226,14 +221,23 @@ for var in sorted(self.object_help.keys()): help += '\n %-12s %s' % (var, self.object_help[var]) if shell is None and self.options.enable_bpython: shell = self.make_bpython_shell() user_shell = self.options.python_shell.lower() if not user_shell: if shell is None: shell = self.make_ipython_v0_11_shell() if shell is None: shell = self.make_ipython_v0_10_shell() if shell is None: shell = self.make_bpython_shell() if shell is None and not self.options.disable_ipython: if shell is None and user_shell == 'ipython': shell = self.make_ipython_v0_11_shell() if shell is None: shell = self.make_ipython_v0_10_shell() if shell is None and user_shell == 'bpython': shell = self.make_bpython_shell() if shell is None: shell = self.make_default_shell() pyramid/tests/test_paster.py
@@ -20,9 +20,8 @@ if patch_options: class Options(object): pass self.options = Options() self.options.disable_ipython = True self.options.enable_bpython = False self.options.setup = None self.options.python_shell = '' cmd.options = self.options return cmd @@ -66,6 +65,7 @@ shell = DummyShell() command.make_ipython_v0_11_shell = lambda: None command.make_ipython_v0_10_shell = lambda: None command.make_bpython_shell = lambda: None command.make_default_shell = lambda: shell command.command() self.assertTrue(self.config_factory.parser) @@ -81,33 +81,15 @@ self.assertTrue(self.bootstrap.closer.called) self.assertTrue(shell.help) def test_command_loads_bpython_shell(self): command = self._makeOne() shell = DummyBPythonShell() command.make_bpython_shell = lambda: shell command.options.enable_bpython = True command.command() self.assertTrue(self.config_factory.parser) self.assertEqual(self.config_factory.parser.filename, '/foo/bar/myapp.ini') self.assertEqual(self.bootstrap.a[0], '/foo/bar/myapp.ini#myapp') self.assertEqual(shell.locals_, { 'app':self.bootstrap.app, 'root':self.bootstrap.root, 'registry':self.bootstrap.registry, 'request':self.bootstrap.request, 'root_factory':self.bootstrap.root_factory, }) self.assertTrue(self.bootstrap.closer.called) self.assertTrue(shell.banner) def test_command_loads_default_shell_with_ipython_disabled(self): def test_command_loads_default_shell_with_unknow_shell(self): command = self._makeOne() shell = DummyShell() bad_shell = DummyShell() command.make_ipython_v0_11_shell = lambda: bad_shell command.make_ipython_v0_10_shell = lambda: bad_shell command.make_bpython_shell = lambda: bad_shell command.make_default_shell = lambda: shell command.options.disable_ipython = True command.options.python_shell = 'unknow_python_shell' command.command() self.assertTrue(self.config_factory.parser) self.assertEqual(self.config_factory.parser.filename, @@ -128,8 +110,9 @@ shell = DummyShell() command.make_ipython_v0_11_shell = lambda: shell command.make_ipython_v0_10_shell = lambda: None command.make_bpython_shell = lambda: None command.make_default_shell = lambda: None command.options.disable_ipython = False command.options.python_shell = 'ipython' command.command() self.assertTrue(self.config_factory.parser) self.assertEqual(self.config_factory.parser.filename, @@ -149,8 +132,9 @@ shell = DummyShell() command.make_ipython_v0_11_shell = lambda: None command.make_ipython_v0_10_shell = lambda: shell command.make_bpython_shell = lambda: None command.make_default_shell = lambda: None command.options.disable_ipython = False command.options.python_shell = 'ipython' command.command() self.assertTrue(self.config_factory.parser) self.assertEqual(self.config_factory.parser.filename, @@ -165,6 +149,27 @@ self.assertTrue(self.bootstrap.closer.called) self.assertTrue(shell.help) def test_command_loads_bpython_shell(self): command = self._makeOne() shell = DummyBPythonShell() command.make_ipython_v0_11_shell = lambda: None command.make_ipython_v0_10_shell = lambda: None command.make_bpython_shell = lambda: shell command.options.python_shell = 'bpython' command.command() self.assertTrue(self.config_factory.parser) self.assertEqual(self.config_factory.parser.filename, '/foo/bar/myapp.ini') self.assertEqual(self.bootstrap.a[0], '/foo/bar/myapp.ini#myapp') self.assertEqual(shell.locals_, { 'app':self.bootstrap.app, 'root':self.bootstrap.root, 'registry':self.bootstrap.registry, 'request':self.bootstrap.request, 'root_factory':self.bootstrap.root_factory, }) self.assertTrue(self.bootstrap.closer.called) self.assertTrue(shell.banner) def test_command_loads_custom_items(self): command = self._makeOne() model = Dummy()