sponsor-patch: Use old Archive Admin way for sync requests until bug #827555 is fixed.

This commit is contained in:
Benjamin Drung 2011-09-15 13:08:06 +02:00
parent 268fea2a1c
commit 5942694e6f
3 changed files with 74 additions and 17 deletions

View File

@ -74,6 +74,10 @@ class BugTask(object):
"Project: " + str(self.project) + "\n" + \ "Project: " + str(self.project) + "\n" + \
"Series: " + str(self.series) "Series: " + str(self.series)
def get_lp_task(self):
"""Returns the Launchpad bug task object."""
return self.bug_task
def get_package_and_series(self): def get_package_and_series(self):
result = self.package result = self.package
if self.series: if self.series:

View File

@ -65,6 +65,51 @@ class SourcePackage(object):
self._version = None self._version = None
self._build_log = None self._build_log = None
def ack_sync(self, upload, task, launchpad):
"""Acknowledge a sync request and subscribe ubuntu-archive."""
if upload == "ubuntu":
self._print_logs()
question = Question(["yes", "edit", "no"])
answer = question.ask("Do you want to acknowledge the sync request",
"no")
if answer == "edit":
return False
elif answer == "no":
user_abort()
bug = task.bug
task.status = "Confirmed"
if task.importance == "Undecided":
task.importance = "Wishlist"
task.lp_save()
Logger.info("Set bug #%i status to Confirmed.", bug.id)
msg = "Sync request ACK'd."
if self._build_log:
msg = ("%s %s builds on %s. " + msg) % \
(self._package, self._version,
self._builder.get_architecture())
bug.newMessage(content=msg, subject="sponsor-patch")
Logger.info("Acknowledged sync request bug #%i.", bug.id)
bug.subscribe(person=launchpad.people['ubuntu-archive'])
Logger.info("Subscribed ubuntu-archive to bug #%i.", bug.id)
bug.subscribe(person=launchpad.me)
Logger.info("Subscribed me to bug #%i.", bug.id)
bug.unsubscribe(person=launchpad.people['ubuntu-sponsors'])
Logger.info("Unsubscribed ubuntu-sponsors from bug #%i.", bug.id)
Logger.normal("Successfully acknowledged sync request bug #%i.",
bug.id)
else:
Logger.error("Acknowledging a sync request other than to the "
"official Ubuntu archive is not supported!")
sys.exit(1)
return True
def ask_and_upload(self, upload): def ask_and_upload(self, upload):
"""Ask the user before uploading the source package. """Ask the user before uploading the source package.
@ -74,17 +119,7 @@ class SourcePackage(object):
# Upload package # Upload package
if upload: if upload:
lintian_filename = self._run_lintian() self._print_logs()
print "\nPlease check %s %s carefully:\nfile://%s\nfile://%s" % \
(self._package, self._version, self._debdiff_filename,
lintian_filename)
if self._build_log:
print "file://%s" % self._build_log
harvest = Harvest(self._package)
if harvest.data:
print harvest.report()
if upload == "ubuntu": if upload == "ubuntu":
target = "the official Ubuntu archive" target = "the official Ubuntu archive"
else: else:
@ -308,6 +343,21 @@ class SourcePackage(object):
return False return False
return True return True
def _print_logs(self):
"""Print things that should be checked before uploading a package."""
lintian_filename = self._run_lintian()
print "\nPlease check %s %s carefully:" % (self._package, self._version)
if os.path.isfile(self._debdiff_filename):
print "file://" + self._debdiff_filename
print "file://" + lintian_filename
if self._build_log:
print "file://" + self._build_log
harvest = Harvest(self._package)
if harvest.data:
print harvest.report()
def reload_changelog(self): def reload_changelog(self):
"""Reloads debian/changelog and update version.""" """Reloads debian/changelog and update version."""
@ -382,3 +432,4 @@ class SourcePackage(object):
Logger.error("Uploading a synced package other than to ubuntu " Logger.error("Uploading a synced package other than to ubuntu "
"is not supported yet!") "is not supported yet!")
sys.exit(1) sys.exit(1)
return True

View File

@ -20,12 +20,12 @@ import pwd
import shutil import shutil
import sys import sys
import launchpadlib.launchpad
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import UbuntuDistroInfo from distro_info import UbuntuDistroInfo
from launchpadlib.launchpad import Launchpad
from ubuntutools import subprocess from ubuntutools import subprocess
from ubuntutools.update_maintainer import update_maintainer from ubuntutools.update_maintainer import update_maintainer
from ubuntutools.question import input_number from ubuntutools.question import input_number
@ -244,8 +244,7 @@ def sponsor_patch(bug_number, build, builder, edit, keyid, lpinstance, update,
workdir = os.path.realpath(os.path.expanduser(workdir)) workdir = os.path.realpath(os.path.expanduser(workdir))
_create_and_change_into(workdir) _create_and_change_into(workdir)
launchpad = launchpadlib.launchpad.Launchpad.login_anonymously( launchpad = Launchpad.login_with("sponsor-patch", lpinstance)
"sponsor-patch", lpinstance)
#pylint: disable=E1101 #pylint: disable=E1101
bug = launchpad.bugs[bug_number] bug = launchpad.bugs[bug_number]
#pylint: enable=E1101 #pylint: enable=E1101
@ -268,10 +267,13 @@ def sponsor_patch(bug_number, build, builder, edit, keyid, lpinstance, update,
update = False update = False
if successful: if successful:
source_package.sync(upload, bug_number, keyid) #if source_package.sync(upload, bug_number, keyid):
if source_package.ack_sync(upload, task.get_lp_task(), launchpad):
return return
else: else:
edit = True edit = True
else:
edit = True
if patch: if patch:
edit |= patch.apply(task) edit |= patch.apply(task)