Use Launchpadlib.login_with() directly in scripts.

This commit is contained in:
Stefano Rivera 2011-03-01 00:30:54 +02:00
parent fe63eaec05
commit 997fb23b2d
10 changed files with 30 additions and 26 deletions

View File

@ -28,8 +28,9 @@ import logging
import glob
import fnmatch
from launchpadlib.launchpad import Launchpad
from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import get_launchpad
COMMAND_LINE_SYNTAX_ERROR = 1
VERSION_DETECTION_FAILED = 2
@ -148,7 +149,7 @@ def unsubscribe_sponsors(launchpad, bug):
def ack_sync(bug_numbers, all_package, all_version, all_section, update,
all_uploader_email, key, upload, lpinstance, pbuilder, sbuild, lvm,
piuparts, verbose=False, silent=False):
launchpad = get_launchpad("ubuntu-dev-tools", server=lpinstance)
launchpad = Launchpad.login_with("ubuntu-dev-tools", lpinstance)
# TODO: use release-info (once available)
series = launchpad.distributions["ubuntu"].current_series
dist = series.name

3
debian/changelog vendored
View File

@ -6,8 +6,9 @@ ubuntu-dev-tools (0.119) UNRELEASED; urgency=low
python-keyring. (LP: #387297, #645629, #689100)
* Remove ubuntutools.lp.libsupport.translate_api_web, no longer used.
* Remove ubuntutools.lp.libsupport.approve_application, no longer used.
* Use Launchpadlib.login_with() directly in scripts.
-- Stefano Rivera <stefanor@debian.org> Mon, 28 Feb 2011 23:55:25 +0200
-- Stefano Rivera <stefanor@debian.org> Tue, 01 Mar 2011 00:30:29 +0200
ubuntu-dev-tools (0.118) unstable; urgency=low

View File

@ -23,8 +23,9 @@ from optparse import OptionParser
import os
import sys
from launchpadlib.launchpad import Launchpad
from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import get_launchpad
USAGE = "grab-attachments <bug numbers>"
@ -45,7 +46,7 @@ def main():
opts.lpinstance = config.get_value('LPINSTANCE')
try:
launchpad = get_launchpad("ubuntu-dev-tools", server=opts.lpinstance)
launchpad = Launchpad.login_with("ubuntu-dev-tools", opts.lpinstance)
for arg in args:
try:

View File

@ -32,7 +32,9 @@
import sys
from optparse import OptionParser
from ubuntutools.lp.libsupport import (get_launchpad, translate_web_api)
from launchpadlib.launchpad import Launchpad
from ubuntutools.lp.libsupport import translate_web_api
def check_args():
howmany = -1
@ -87,7 +89,7 @@ def main():
launchpad = None
try:
launchpad = get_launchpad("ubuntu-dev-tools")
launchpad = Launchpad.login_with("ubuntu-dev-tools", 'production')
except IOError, error:
print error
sys.exit(1)

View File

@ -34,8 +34,9 @@ except ImportError:
"this utility.")
sys.exit(1)
from launchpadlib.launchpad import Launchpad
from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import get_launchpad
def main():
bug_re = re.compile(r"bug=(\d+)")
@ -73,7 +74,7 @@ def main():
options.lpinstance = config.get_value("LPINSTANCE")
try:
launchpad = get_launchpad("ubuntu-dev-tools", options.lpinstance)
launchpad = Launchpad.login_with("ubuntu-dev-tools", options.lpinstance)
except IOError, msg:
print msg
print "No credentials, can't continue"

View File

@ -23,10 +23,9 @@
# Colin Watson <cjwatson@ubuntu.com>
import sys
from optparse import OptionParser
from ubuntutools.lp.libsupport import get_launchpad
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
def main():
@ -37,7 +36,7 @@ def main():
parser.error("Need at least one bug number")
try:
launchpad = get_launchpad('ubuntu-dev-tools')
launchpad = Launchpad.login_with('ubuntu-dev-tools', 'production')
except Exception, error:
print >> sys.stderr, 'Could not connect to Launchpad:', str(error)
sys.exit(2)

View File

@ -24,7 +24,7 @@ import subprocess
import sys
import tempfile
from ubuntutools.lp.libsupport import get_launchpad
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
def create_release(project, version):
@ -88,7 +88,7 @@ def main():
(project, version, tarball) = sys.argv[1:]
try:
launchpad = get_launchpad('ubuntu-dev-tools')
launchpad = Launchpad.login_with('ubuntu-dev-tools', 'production')
except Exception, error:
print >> sys.stderr, 'Could not connect to Launchpad:', str(error)
sys.exit(2)

View File

@ -25,9 +25,9 @@
import sys
from optparse import OptionParser
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
import ubuntutools.lp.libsupport as lp_libsupport
from ubuntutools.config import UDTConfig
def die(message):
@ -60,8 +60,7 @@ def main():
launchpad = None
try:
print "Setting up Launchpad"
launchpad = lp_libsupport.get_launchpad("ubuntu-dev-tools",
server=options.lpinstance)
launchpad = Launchpad.login_with("ubuntu-dev-tools", options.lpinstance)
print "Launchpad setup complete"
except ImportError:
suggestion = "check whether python-launchpadlib is installed"

View File

@ -28,9 +28,10 @@ import os
import sys
import email
from launchpadlib.launchpad import Launchpad
from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import (get_launchpad,
translate_web_api)
from ubuntutools.lp.libsupport import translate_web_api
def read_config():
instructions_file = open("instructions")
@ -164,7 +165,7 @@ def main():
if not check_configfiles():
sys.exit(1)
launchpad = get_launchpad('ubuntu-dev-tools', server=options.lpinstance)
launchpad = Launchpad.login_with('ubuntu-dev-tools', options.lpinstance)
config = read_config()
pack_list = read_list()
buglist = read_buglist(config["buglist-url"], launchpad)

View File

@ -26,11 +26,10 @@
import sys
import launchpadlib.launchpad as launchpad
from launchpadlib.launchpad import Launchpad as LP
from launchpadlib.errors import HTTPError
from lazr.restfulclient.resource import Entry
import ubuntutools.lp.libsupport as libsupport
from ubuntutools.lp import (service, api_version)
from ubuntutools.lp.udtexceptions import (AlreadyLoggedInError,
ArchiveNotFoundException,
@ -58,8 +57,8 @@ class _Launchpad(object):
'''Enforce a non-anonymous login.'''
if not self.logged_in:
try:
self.__lp = libsupport.get_launchpad('ubuntu-dev-tools',
server=service)
self.__lp = LP.login_with('ubuntu-dev-tools', service,
version=api_version)
except IOError, error:
print >> sys.stderr, 'E: %s' % error
raise
@ -69,8 +68,8 @@ class _Launchpad(object):
def login_anonymously(self, service=service, api_version=api_version):
'''Enforce an anonymous login.'''
if not self.logged_in:
self.__lp = launchpad.Launchpad.login_anonymously(
'ubuntu-dev-tools', service_root=service, version=api_version)
self.__lp = LP.login_anonymously('ubuntu-dev-tools', service,
version=api_version)
else:
raise AlreadyLoggedInError('Already logged in to Launchpad.')