From 997fb23b2d8a64c9778b12444364b2c005a253b7 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Tue, 1 Mar 2011 00:30:54 +0200 Subject: [PATCH] Use Launchpadlib.login_with() directly in scripts. --- ack-sync | 5 +++-- debian/changelog | 3 ++- grab-attachments | 5 +++-- hugdaylist | 6 ++++-- import-bug-from-debian | 5 +++-- lp-list-bugs | 5 ++--- lp-project-upload | 4 ++-- lp-set-dup | 5 ++--- massfile | 7 ++++--- ubuntutools/lp/lpapicache.py | 11 +++++------ 10 files changed, 30 insertions(+), 26 deletions(-) diff --git a/ack-sync b/ack-sync index 6c8cd7a..c44121d 100755 --- a/ack-sync +++ b/ack-sync @@ -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 diff --git a/debian/changelog b/debian/changelog index c0f6020..4ebd700 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Mon, 28 Feb 2011 23:55:25 +0200 + -- Stefano Rivera Tue, 01 Mar 2011 00:30:29 +0200 ubuntu-dev-tools (0.118) unstable; urgency=low diff --git a/grab-attachments b/grab-attachments index 6144f3c..51771cc 100755 --- a/grab-attachments +++ b/grab-attachments @@ -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 " @@ -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: diff --git a/hugdaylist b/hugdaylist index 20f885c..936a98c 100755 --- a/hugdaylist +++ b/hugdaylist @@ -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) diff --git a/import-bug-from-debian b/import-bug-from-debian index 13a157f..0b01036 100755 --- a/import-bug-from-debian +++ b/import-bug-from-debian @@ -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" diff --git a/lp-list-bugs b/lp-list-bugs index 9d1496c..76c3db8 100755 --- a/lp-list-bugs +++ b/lp-list-bugs @@ -23,10 +23,9 @@ # Colin Watson 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) diff --git a/lp-project-upload b/lp-project-upload index 1b62295..7931f2c 100755 --- a/lp-project-upload +++ b/lp-project-upload @@ -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) diff --git a/lp-set-dup b/lp-set-dup index fcda69a..8df0cea 100755 --- a/lp-set-dup +++ b/lp-set-dup @@ -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" diff --git a/massfile b/massfile index 65cd8f4..5ad6270 100755 --- a/massfile +++ b/massfile @@ -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) diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index ea5ef95..097b63f 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -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.')