* requestsync: Introduce some first LpApiWrapper use.

This commit is contained in:
Michael Bienia 2009-06-12 00:48:41 +02:00
parent d4f6f9079e
commit f60a86b68d

View File

@ -39,6 +39,7 @@ from time import sleep
import ubuntutools.lp.functions as lp_functions import ubuntutools.lp.functions as lp_functions
import ubuntutools.lp.libsupport as lp_libsupport import ubuntutools.lp.libsupport as lp_libsupport
import ubuntutools.lp.udtexceptions as udtexceptions import ubuntutools.lp.udtexceptions as udtexceptions
from ubuntutools.lp.lpapiwrapper import Launchpad, LpApiWrapper
# https_proxy fix # https_proxy fix
import ubuntutools.common import ubuntutools.common
import ubuntutools.packages import ubuntutools.packages
@ -78,7 +79,7 @@ def checkExistingReports(package):
launchpad = None launchpad = None
try: try:
launchpad = lp_libsupport.get_launchpad("ubuntu-dev-tools") launchpad = Launchpad.login()
except ImportError: except ImportError:
print >> sys.stderr, 'Importing launchpadlib failed. Is ' \ print >> sys.stderr, 'Importing launchpadlib failed. Is ' \
'python-launchpadlib installed?' 'python-launchpadlib installed?'
@ -95,7 +96,7 @@ def checkExistingReports(package):
return False return False
# Fetch the package's bug list from Launchpad. # Fetch the package's bug list from Launchpad.
pkg = launchpad.distributions["ubuntu"].getSourcePackage(name=package) pkg = launchpad.getUbuntuDistribution().getSourcePackage(name=package)
pkgBugList = pkg.searchTasks() pkgBugList = pkg.searchTasks()
# Search bug list for other sync requests. # Search bug list for other sync requests.
@ -323,7 +324,7 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext):
import glob, os.path import glob, os.path
try: try:
launchpad = lp_libsupport.get_launchpad("ubuntu-dev-tools") launchpad = Launchpad.login()
except ImportError: except ImportError:
print >> sys.stderr, 'Importing launchpadlib failed. Is python-launchpadlib installed?' print >> sys.stderr, 'Importing launchpadlib failed. Is python-launchpadlib installed?'
return False return False
@ -362,8 +363,9 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext):
task = bug.bug_tasks[0] task = bug.bug_tasks[0]
# Only members of ubuntu-bugcontrol can set importance # Only members of ubuntu-bugcontrol can set importance
if lp_functions.isLPTeamMember('ubuntu-bugcontrol'): if lp_functions.isLPTeamMember('ubuntu-bugcontrol'):
task.transitionToImportance(importance='Wishlist') task.importance = 'Wishlist'
task.transitionToStatus(status=status) task.status = status
task.lp_save()
subscribe_url = "%s~%s" %(launchpad._root_uri, subscribe) subscribe_url = "%s~%s" %(launchpad._root_uri, subscribe)
bug.subscribe(person=subscribe_url) bug.subscribe(person=subscribe_url)
@ -463,16 +465,16 @@ if __name__ == '__main__':
distro = options.dist distro = options.dist
ffe = options.ffe ffe = options.ffe
if not use_lp_bugs and not get_email_address():
sys.exit(1)
if len(args) not in (2, 3): # no release specified, assume development release if len(args) not in (2, 3): # no release specified, assume development release
release = lp_functions.ubuntuDevelopmentSeries() release = LpApiWrapper.getUbuntuDevelopmentSeries().name
print >> sys.stderr, ("Source package / target release missing - assuming %s " % print >> sys.stderr, ("Source package / target release missing - assuming %s " %
release) release)
else: else:
release = args[1] release = args[1]
if not use_lp_bugs and not get_email_address():
sys.exit(1)
srcpkg = args[0] srcpkg = args[0]
force_base_ver = None force_base_ver = None