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 glob
import fnmatch import fnmatch
from launchpadlib.launchpad import Launchpad
from ubuntutools.config import UDTConfig from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import get_launchpad
COMMAND_LINE_SYNTAX_ERROR = 1 COMMAND_LINE_SYNTAX_ERROR = 1
VERSION_DETECTION_FAILED = 2 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, def ack_sync(bug_numbers, all_package, all_version, all_section, update,
all_uploader_email, key, upload, lpinstance, pbuilder, sbuild, lvm, all_uploader_email, key, upload, lpinstance, pbuilder, sbuild, lvm,
piuparts, verbose=False, silent=False): 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) # TODO: use release-info (once available)
series = launchpad.distributions["ubuntu"].current_series series = launchpad.distributions["ubuntu"].current_series
dist = series.name 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) python-keyring. (LP: #387297, #645629, #689100)
* Remove ubuntutools.lp.libsupport.translate_api_web, no longer used. * Remove ubuntutools.lp.libsupport.translate_api_web, no longer used.
* Remove ubuntutools.lp.libsupport.approve_application, 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 ubuntu-dev-tools (0.118) unstable; urgency=low

View File

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

View File

@ -32,7 +32,9 @@
import sys import sys
from optparse import OptionParser 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(): def check_args():
howmany = -1 howmany = -1
@ -87,7 +89,7 @@ def main():
launchpad = None launchpad = None
try: try:
launchpad = get_launchpad("ubuntu-dev-tools") launchpad = Launchpad.login_with("ubuntu-dev-tools", 'production')
except IOError, error: except IOError, error:
print error print error
sys.exit(1) sys.exit(1)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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