bpython is amazing
This commit is contained in:
		| @@ -135,15 +135,48 @@ 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. | ||||||
|         try: |  | ||||||
|             import IPython |         Falls back to Ipython/python shell if unavailable""" | ||||||
|             # Explicitly pass an empty list as arguments, because otherwise IPython |         self.run('bpython') | ||||||
|             # would use sys.argv from this script. |  | ||||||
|             shell = IPython.Shell.IPShell(argv=[]) |     def ipython(self): | ||||||
|             shell.mainloop() |         """Runs an Ipython shell. | ||||||
|         except ImportError: |  | ||||||
|  |         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: | ||||||
|  |                 import IPython | ||||||
|  |                 # Explicitly pass an empty list as arguments, because otherwise IPython | ||||||
|  |                 # would use sys.argv from this script. | ||||||
|  |                 shell = IPython.Shell.IPShell(argv=[]) | ||||||
|  |                 shell.mainloop() | ||||||
|  |             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
	 Vishvananda Ishaya
					Vishvananda Ishaya