bpython is amazing
This commit is contained in:
@@ -135,8 +135,38 @@ class VpnCommands(object):
|
|||||||
|
|
||||||
|
|
||||||
class ShellCommands(object):
|
class ShellCommands(object):
|
||||||
def run(self):
|
def bpython(self):
|
||||||
"Runs a Python interactive interpreter. Tries to use IPython, if it's available."
|
"""Runs a bpython shell.
|
||||||
|
|
||||||
|
Falls back to Ipython/python shell if unavailable"""
|
||||||
|
self.run('bpython')
|
||||||
|
|
||||||
|
def ipython(self):
|
||||||
|
"""Runs an Ipython shell.
|
||||||
|
|
||||||
|
Falls back to Python shell if unavailable"""
|
||||||
|
self.run('ipython')
|
||||||
|
|
||||||
|
def python(self):
|
||||||
|
"""Runs an python shell.
|
||||||
|
|
||||||
|
Falls back to Python shell if unavailable"""
|
||||||
|
self.run('python')
|
||||||
|
|
||||||
|
def run(self, shell=None):
|
||||||
|
"""Runs a Python interactive interpreter.
|
||||||
|
|
||||||
|
args: [shell=bpython]"""
|
||||||
|
if not shell:
|
||||||
|
shell = 'bpython'
|
||||||
|
|
||||||
|
if shell == 'bpython':
|
||||||
|
try:
|
||||||
|
import bpython
|
||||||
|
bpython.embed()
|
||||||
|
except ImportError:
|
||||||
|
shell = 'ipython'
|
||||||
|
if shell == 'ipython':
|
||||||
try:
|
try:
|
||||||
import IPython
|
import IPython
|
||||||
# Explicitly pass an empty list as arguments, because otherwise IPython
|
# Explicitly pass an empty list as arguments, because otherwise IPython
|
||||||
@@ -144,6 +174,9 @@ class ShellCommands(object):
|
|||||||
shell = IPython.Shell.IPShell(argv=[])
|
shell = IPython.Shell.IPShell(argv=[])
|
||||||
shell.mainloop()
|
shell.mainloop()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
shell = 'python'
|
||||||
|
|
||||||
|
if shell == 'python':
|
||||||
import code
|
import code
|
||||||
try: # Try activating rlcompleter, because it's handy.
|
try: # Try activating rlcompleter, because it's handy.
|
||||||
import readline
|
import readline
|
||||||
|
|||||||
Reference in New Issue
Block a user