mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
lp-shell: use ipython shell if available
suggest ipython and when available use it instead of the regular python shell
This commit is contained in:
parent
5762512710
commit
3449fc6a64
2
debian/control
vendored
2
debian/control
vendored
@ -57,7 +57,7 @@ Recommends: bzr,
|
||||
python-gnupginterface,
|
||||
python-soappy,
|
||||
reportbug (>= 3.39ubuntu1)
|
||||
Suggests: python-simplejson | python (>= 2.7), qemu-user-static
|
||||
Suggests: ipython, python-simplejson | python (>= 2.7), qemu-user-static
|
||||
Description: useful tools for Ubuntu developers
|
||||
This is a collection of useful tools that Ubuntu developers use to make their
|
||||
packaging work a lot easier.
|
||||
|
43
lp-shell
43
lp-shell
@ -63,24 +63,35 @@ def main():
|
||||
|
||||
banner += '\nNote: LP can be accessed through the "lp" object.'
|
||||
|
||||
class CompleterConsole(code.InteractiveConsole):
|
||||
def __init__(self):
|
||||
local = {'lp': launchpad}
|
||||
code.InteractiveConsole.__init__(self, locals=local)
|
||||
try:
|
||||
import readline
|
||||
except ImportError:
|
||||
print 'I: readline module not available.'
|
||||
else:
|
||||
import rlcompleter
|
||||
readline.parse_and_bind("tab: complete")
|
||||
try:
|
||||
try: # ipython >= 0.11
|
||||
from IPython.frontend.terminal.embed import InteractiveShellEmbed
|
||||
sh = InteractiveShellEmbed(banner2=banner, user_ns={'lp': launchpad})
|
||||
except ImportError: # ipython < 0.11
|
||||
from IPython.Shell import IPShellEmbed
|
||||
sh = IPShellEmbed(user_ns={'lp': launchpad})
|
||||
sh.set_banner(sh.IP.BANNER + '\n' + banner)
|
||||
sh.excepthook = sys.__excepthook__
|
||||
sh()
|
||||
except ImportError:
|
||||
class CompleterConsole(code.InteractiveConsole):
|
||||
def __init__(self):
|
||||
local = {'lp': launchpad}
|
||||
code.InteractiveConsole.__init__(self, locals=local)
|
||||
try:
|
||||
import readline
|
||||
except ImportError:
|
||||
print 'I: readline module not available.'
|
||||
else:
|
||||
import rlcompleter
|
||||
readline.parse_and_bind("tab: complete")
|
||||
|
||||
# Disable default apport hook, as lp-shell is intended for interactive use
|
||||
# and thus exceptions often bubble up to the top level.
|
||||
sys.excepthook = sys.__excepthook__
|
||||
# Disable default apport hook, as lp-shell is intended for interactive use
|
||||
# and thus exceptions often bubble up to the top level.
|
||||
sys.excepthook = sys.__excepthook__
|
||||
|
||||
console = CompleterConsole()
|
||||
console.interact(banner)
|
||||
console = CompleterConsole()
|
||||
console.interact(banner)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user