mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-13 01:41:29 +00:00
[ Stefano Rivera ]
[ Julian Taylor ] lp-shell: use ipython shell if available
This commit is contained in:
commit
7acdaaf977
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,8 +1,12 @@
|
|||||||
ubuntu-dev-tools (0.128) UNRELEASED; urgency=low
|
ubuntu-dev-tools (0.128) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
[ Stefano Rivera ]
|
||||||
* ubuntutools.builder: Detect missing builder and fail early.
|
* ubuntutools.builder: Detect missing builder and fail early.
|
||||||
|
|
||||||
-- Stefano Rivera <stefanor@debian.org> Mon, 25 Jul 2011 19:36:41 +0200
|
[ Julian Taylor ]
|
||||||
|
* lp-shell: use ipython shell if available
|
||||||
|
|
||||||
|
-- Julian Taylor <jtaylor.debian@googlemail.com> Sun, 14 Aug 2011 18:56:52 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.127) unstable; urgency=low
|
ubuntu-dev-tools (0.127) unstable; urgency=low
|
||||||
|
|
||||||
|
2
debian/control
vendored
2
debian/control
vendored
@ -57,7 +57,7 @@ Recommends: bzr,
|
|||||||
python-gnupginterface,
|
python-gnupginterface,
|
||||||
python-soappy,
|
python-soappy,
|
||||||
reportbug (>= 3.39ubuntu1)
|
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
|
Description: useful tools for Ubuntu developers
|
||||||
This is a collection of useful tools that Ubuntu developers use to make their
|
This is a collection of useful tools that Ubuntu developers use to make their
|
||||||
packaging work a lot easier.
|
packaging work a lot easier.
|
||||||
|
@ -5,6 +5,8 @@ lp\-shell \- Open an interactive launchpadlib shell.
|
|||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B lp\-shell
|
.B lp\-shell
|
||||||
.RB [ \-a ]
|
.RB [ \-a ]
|
||||||
|
.RB [ \-\-python ]
|
||||||
|
.RB [ \-\-ipython ]
|
||||||
.RI [ service ]
|
.RI [ service ]
|
||||||
.RI [ "LP API version" ]
|
.RI [ "LP API version" ]
|
||||||
|
|
||||||
@ -34,6 +36,14 @@ the third argument. Current supported are: "beta", "1.0" and "devel".
|
|||||||
.B \-a
|
.B \-a
|
||||||
Login anonymously into Launchpad.
|
Login anonymously into Launchpad.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-ipython
|
||||||
|
Use an ipython shell if available (default).
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-python
|
||||||
|
Use a regular python shell.
|
||||||
|
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
.B lp\-shell
|
.B lp\-shell
|
||||||
was written by Martin Pitt <martin.pitt@ubuntu.com>.
|
was written by Martin Pitt <martin.pitt@ubuntu.com>.
|
||||||
|
58
lp-shell
58
lp-shell
@ -33,6 +33,13 @@ def main():
|
|||||||
opt_parser.add_option('-a', action='store_true',
|
opt_parser.add_option('-a', action='store_true',
|
||||||
dest='anonymous', default=False,
|
dest='anonymous', default=False,
|
||||||
help='Login anonymously into LP.')
|
help='Login anonymously into LP.')
|
||||||
|
opt_parser.add_option('--ipython',action='store_const',
|
||||||
|
dest='shell',const='ipython', default="ipython",
|
||||||
|
help='Use ipython shell (default).')
|
||||||
|
opt_parser.add_option('--python',action='store_const',
|
||||||
|
dest='shell',const='python',
|
||||||
|
help='Use python shell.')
|
||||||
|
|
||||||
|
|
||||||
(options, args) = opt_parser.parse_args()
|
(options, args) = opt_parser.parse_args()
|
||||||
|
|
||||||
@ -63,24 +70,43 @@ def main():
|
|||||||
|
|
||||||
banner += '\nNote: LP can be accessed through the "lp" object.'
|
banner += '\nNote: LP can be accessed through the "lp" object.'
|
||||||
|
|
||||||
class CompleterConsole(code.InteractiveConsole):
|
sh = None
|
||||||
def __init__(self):
|
if options.shell == "ipython":
|
||||||
local = {'lp': launchpad}
|
try:
|
||||||
code.InteractiveConsole.__init__(self, locals=local)
|
try: # ipython >= 0.11
|
||||||
try:
|
from IPython.frontend.terminal.embed import InteractiveShellEmbed
|
||||||
import readline
|
sh = InteractiveShellEmbed(banner2=banner, user_ns={'lp': launchpad})
|
||||||
except ImportError:
|
except ImportError: # ipython < 0.11
|
||||||
print 'I: readline module not available.'
|
# pylint does not handle nested try-except, disable import error
|
||||||
else:
|
# pylint: disable-msg=E0611
|
||||||
import rlcompleter
|
from IPython.Shell import IPShellEmbed
|
||||||
readline.parse_and_bind("tab: complete")
|
sh = IPShellEmbed(argv=[], user_ns={'lp': launchpad})
|
||||||
|
sh.set_banner(sh.IP.BANNER + '\n' + banner)
|
||||||
|
sh.excepthook = sys.__excepthook__
|
||||||
|
except ImportError:
|
||||||
|
print "E: ipython not available. Using normal python shell."
|
||||||
|
|
||||||
# Disable default apport hook, as lp-shell is intended for interactive use
|
if sh:
|
||||||
# and thus exceptions often bubble up to the top level.
|
sh()
|
||||||
sys.excepthook = sys.__excepthook__
|
else:
|
||||||
|
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")
|
||||||
|
|
||||||
console = CompleterConsole()
|
# Disable default apport hook, as lp-shell is intended for interactive use
|
||||||
console.interact(banner)
|
# and thus exceptions often bubble up to the top level.
|
||||||
|
sys.excepthook = sys.__excepthook__
|
||||||
|
|
||||||
|
console = CompleterConsole()
|
||||||
|
console.interact(banner)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user