mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-24 17:31:09 +00:00
lp-shell: add cmd-line options to set used shell
This commit is contained in:
parent
d0afcbd295
commit
5f374b192b
@ -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 a 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>.
|
||||||
|
15
lp-shell
15
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='mode',const='ipython', default="ipython",
|
||||||
|
help='Use ipython shell (default).')
|
||||||
|
opt_parser.add_option('--python',action='store_const',
|
||||||
|
dest='mode',const='python',
|
||||||
|
help='Use python shell.')
|
||||||
|
|
||||||
|
|
||||||
(options, args) = opt_parser.parse_args()
|
(options, args) = opt_parser.parse_args()
|
||||||
|
|
||||||
@ -63,6 +70,8 @@ def main():
|
|||||||
|
|
||||||
banner += '\nNote: LP can be accessed through the "lp" object.'
|
banner += '\nNote: LP can be accessed through the "lp" object.'
|
||||||
|
|
||||||
|
sh = None
|
||||||
|
if options.mode == "ipython":
|
||||||
try:
|
try:
|
||||||
try: # ipython >= 0.11
|
try: # ipython >= 0.11
|
||||||
from IPython.frontend.terminal.embed import InteractiveShellEmbed
|
from IPython.frontend.terminal.embed import InteractiveShellEmbed
|
||||||
@ -72,8 +81,12 @@ def main():
|
|||||||
sh = IPShellEmbed(user_ns={'lp': launchpad})
|
sh = IPShellEmbed(user_ns={'lp': launchpad})
|
||||||
sh.set_banner(sh.IP.BANNER + '\n' + banner)
|
sh.set_banner(sh.IP.BANNER + '\n' + banner)
|
||||||
sh.excepthook = sys.__excepthook__
|
sh.excepthook = sys.__excepthook__
|
||||||
sh()
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
print "E: ipython not available. Using normal python shell."
|
||||||
|
|
||||||
|
if sh:
|
||||||
|
sh()
|
||||||
|
else:
|
||||||
class CompleterConsole(code.InteractiveConsole):
|
class CompleterConsole(code.InteractiveConsole):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
local = {'lp': launchpad}
|
local = {'lp': launchpad}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user