mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-14 00:21:08 +00:00
lp-shell:
+ Add support for using different LP API versions. + Add option to login anonymously into LP. doc/lp-shell.1: Update the documentation.
This commit is contained in:
parent
28f7abc2d4
commit
e8722696bf
8
debian/changelog
vendored
8
debian/changelog
vendored
@ -1,8 +1,10 @@
|
||||
ubuntu-dev-tools (0.97) UNRELEASED; urgency=low
|
||||
|
||||
[ Michael Bienia ]
|
||||
* lp-shell: Support all to the launchpadlib Python module known service
|
||||
names.
|
||||
* lp-shell:
|
||||
+ Support all known LP service names.
|
||||
+ Add support for using different LP API versions.
|
||||
+ Add option to login anonymously into LP.
|
||||
* ubuntutools/lp/lpapicache.py, ubuntutools/lp/libsupport.py: Add support
|
||||
for different LP API versions.
|
||||
* ubuntutools/lp/__init__.py: Set the '1.0' LP API version as default.
|
||||
@ -13,7 +15,7 @@ ubuntu-dev-tools (0.97) UNRELEASED; urgency=low
|
||||
* Apply patch from Julian Andres Klode for the python-apt 0.8 API transition
|
||||
(Closes: #572091)
|
||||
|
||||
-- Michael Bienia <geser@ubuntu.com> Thu, 25 Mar 2010 21:58:47 +0100
|
||||
-- Michael Bienia <geser@ubuntu.com> Sat, 27 Mar 2010 20:14:24 +0100
|
||||
|
||||
ubuntu-dev-tools (0.96) lucid; urgency=low
|
||||
|
||||
|
@ -1,26 +1,39 @@
|
||||
.TH lp-shell "1" "13 January 2010" "ubuntu-dev-tools"
|
||||
.TH lp-shell "1" "27 March 2010" "ubuntu-dev-tools"
|
||||
.SH NAME
|
||||
lp\-shell \- Open an interactive launchpadlib shell.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B lp\-shell
|
||||
[service]
|
||||
.RB [ \-a ]
|
||||
.RI [ service ]
|
||||
.RI [ "LP API version" ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B lp\-shell
|
||||
opens an interactive Python shell with a launchpadlib.Launchpad object "lp"
|
||||
which is ready for use.
|
||||
|
||||
It authenticates against Launchpad with the consumer name "test".
|
||||
It authenticates against Launchpad with the consumer name "test". When using
|
||||
\fBlp\-shell\fR with the \fB\-a\fR option it will use the anonymous login
|
||||
from launchpadlib.Launchpad.
|
||||
|
||||
It uses by default the "edge" Launchpad service and the default API version.
|
||||
If you want to connect to an other Launchpad service, call
|
||||
.B lp\-shell
|
||||
with the service name as the second argument. lp-shell supports all services
|
||||
By default \fBlp\-shell\fR connects to the "\fIedge\fR" Launchpad service
|
||||
using the "\fI1.0\fR" LP API version.
|
||||
|
||||
If you want to connect to an other Launchpad service, call \fBlp\-shell\fR with
|
||||
the service name as the second argument. \fBlp\-shell\fR supports all services
|
||||
known by launchpadlib Python module.
|
||||
Currently known are (list can be incomplete or outdated): "production", "edge",
|
||||
"staging", "dogfood".
|
||||
|
||||
A different LP API version can be selected by passing the API version to use as
|
||||
the third argument. Current supported are: "beta", "1.0" and "devel".
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-a
|
||||
Login anonymously into Launchpad.
|
||||
|
||||
.SH AUTHORS
|
||||
.B lp\-shell
|
||||
was written by Martin Pitt <martin.pitt@ubuntu.com>.
|
||||
|
62
lp-shell
62
lp-shell
@ -1,7 +1,8 @@
|
||||
#!/usr/bin/python -i
|
||||
#!/usr/bin/python
|
||||
|
||||
# open an interactive launchpadlib Python shell. If the first command line
|
||||
# argument is "staging", this will be on staging instead of production.
|
||||
# Open an interactive launchpadlib Python shell.
|
||||
# It supports all known LP service instances and API versions. The login
|
||||
# can optionally happen anonymously.
|
||||
|
||||
# Author: Martin Pitt <martin.pitt@ubuntu.com>
|
||||
# Copyright: (C) 2010 Canonical Ltd.
|
||||
@ -15,21 +16,66 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
import code, os, sys
|
||||
import sys
|
||||
import code
|
||||
from optparse import OptionParser
|
||||
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
from launchpadlib.uris import lookup_service_root
|
||||
|
||||
instance = 'edge'
|
||||
if len(sys.argv) >= 2:
|
||||
valid_api_versions = ('beta', '1.0', 'devel')
|
||||
api_version = '1.0'
|
||||
|
||||
usage = 'Usage: %prog [-a] [instance] [LP API version]'
|
||||
optParser = OptionParser(usage)
|
||||
optParser.add_option('-a', action='store_true',
|
||||
dest='anonymous', default=False,
|
||||
help='Login anonymously into LP.')
|
||||
|
||||
(options, args) = optParser.parse_args()
|
||||
|
||||
if len(args) >= 1:
|
||||
try:
|
||||
instance = lookup_service_root(sys.argv[1])
|
||||
instance = lookup_service_root(args[0])
|
||||
except ValueError, err:
|
||||
print 'E: %s' % (err)
|
||||
print 'W: Falling back to "edge"'
|
||||
print 'I: Falling back to "edge".'
|
||||
|
||||
lp = Launchpad.login_with('test', instance)
|
||||
if len(args) >= 2:
|
||||
if args[1] in valid_api_versions:
|
||||
api_version = args[1]
|
||||
else:
|
||||
print 'E: "%s" is not a valid LP API version.' % (args[1])
|
||||
print 'I: Falling back to "1.0".'
|
||||
|
||||
if options.anonymous:
|
||||
lp = Launchpad.login_anonymously('test', instance, version=api_version)
|
||||
banner = 'Connected anonymously to LP service "%s" with API version "%s":' % (
|
||||
instance, api_version)
|
||||
else:
|
||||
lp = Launchpad.login_with('test', instance, version=api_version)
|
||||
banner = 'Connected to LP service "%s" with API version "%s":' % (
|
||||
instance, api_version)
|
||||
|
||||
banner += '\nNote: LP can be accessed through the "lp" object.'
|
||||
|
||||
class CompleterConsole(code.InteractiveConsole):
|
||||
def __init__(self):
|
||||
local = {'lp': lp}
|
||||
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__
|
||||
|
||||
console = CompleterConsole()
|
||||
console.interact(banner)
|
||||
|
Loading…
x
Reference in New Issue
Block a user