mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +00:00
154 lines
4.3 KiB
Plaintext
154 lines
4.3 KiB
Plaintext
|
#!/usr/bin/python
|
||
|
|
||
|
from launchpadlib.launchpad import (
|
||
|
STAGING_SERVICE_ROOT,
|
||
|
EDGE_SERVICE_ROOT,
|
||
|
)
|
||
|
from optparse import OptionParser
|
||
|
import re
|
||
|
import SOAPpy
|
||
|
import sys
|
||
|
import subprocess
|
||
|
import ubuntutools.lp.libsupport as lp_libsupport
|
||
|
|
||
|
bug_re = re.compile(r"bug=(\d+)")
|
||
|
|
||
|
url = 'http://bugs.debian.org/cgi-bin/soap.cgi'
|
||
|
namespace = 'Debbugs/SOAP'
|
||
|
debbugs = SOAPpy.SOAPProxy(url, namespace)
|
||
|
|
||
|
# debug
|
||
|
#debbugs.config.dumpSOAPOut = 1
|
||
|
#debbugs.config.dumpSOAPIn = 1
|
||
|
|
||
|
parser = OptionParser()
|
||
|
parser.add_option("-n", "--dry-run",
|
||
|
help="Use the staging server so that changes are not permanent",
|
||
|
dest="dry_run", action="store_true")
|
||
|
parser.add_option("-b", "--browserless",
|
||
|
help="Don't open the bug in the browser at the end",
|
||
|
dest="browserless", action="store_true")
|
||
|
(options, args) = parser.parse_args()
|
||
|
|
||
|
if options.dry_run:
|
||
|
lp_server = STAGING_SERVICE_ROOT
|
||
|
lp_web_base = "https://staging.launchpad.net/"
|
||
|
else:
|
||
|
lp_server = EDGE_SERVICE_ROOT
|
||
|
lp_web_base = "https://staging.launchpad.net/"
|
||
|
|
||
|
try:
|
||
|
lp = lp_libsupport.get_launchpad("ubuntu-dev-tools", lp_server)
|
||
|
except IOError, msg:
|
||
|
print msg
|
||
|
print "No credentials, can't continue"
|
||
|
sys.exit(1)
|
||
|
|
||
|
debian = lp.distributions['debian']
|
||
|
ubuntu = lp.distributions['ubuntu']
|
||
|
lp_debbugs = lp.bugs[262256].bug_watches[0].bug_tracker
|
||
|
|
||
|
bug_nums = []
|
||
|
|
||
|
for bug_num in args:
|
||
|
if bug_num.startswith("http"):
|
||
|
# bug URL
|
||
|
match = bug_re.search(bug_num)
|
||
|
if match is None:
|
||
|
raise ValueError("Can't determine bug number from %s" % bug_num)
|
||
|
bug_num = match.groups()[0]
|
||
|
bug_num = bug_num.lstrip("#")
|
||
|
bug_num = int(bug_num)
|
||
|
bug_nums.append(bug_num)
|
||
|
|
||
|
bugs = debbugs.get_status(*bug_nums)
|
||
|
|
||
|
if len(bug_nums) > 1:
|
||
|
bugs = bugs[0]
|
||
|
|
||
|
import pdb; pdb.set_trace()
|
||
|
for bug in bugs:
|
||
|
bug = bug.value
|
||
|
package = bug.package
|
||
|
bug_num = bug.bug_num
|
||
|
subject = bug.subject
|
||
|
log = debbugs.get_bug_log(bug_num)
|
||
|
summary = log[0][0]
|
||
|
target = ubuntu.getSourcePackage(name=package)
|
||
|
u_bug = lp.bugs.createBug(target=target, title=subject,
|
||
|
description="Imported from Debian bug %d:\n\n%s"
|
||
|
% (bug_num, summary))
|
||
|
d_task = u_bug.addTask(target=debian.getSourcePackage(name=package))
|
||
|
d_watch = u_bug.addWatch(remote_bug=bug_num, bug_tracker=lp_debbugs)
|
||
|
d_task.bug_watch = d_watch
|
||
|
d_task.lp_save()
|
||
|
web_url = "%s/ubuntu/+source/%s/+bug/%d" % (lp_web_base, package, u_bug.id)
|
||
|
print "Opened %s" % web_url
|
||
|
if not options.browserless:
|
||
|
subprocess.call(["xdg-open", web_url])
|
||
|
|
||
|
#def get_status(*args):
|
||
|
# result = server.get_status(*args)
|
||
|
# return result
|
||
|
#
|
||
|
#def get_bugs(*args):
|
||
|
# result = server.get_bugs(*args)
|
||
|
# return result
|
||
|
#
|
||
|
#def get_usertag(email, *tags):
|
||
|
# result = server.get_usertag(email, *tags)
|
||
|
# return result
|
||
|
#
|
||
|
#def get_bug_log(bugnumber):
|
||
|
# result = server.get_bug_log(bugnumber)
|
||
|
# return result
|
||
|
#
|
||
|
#def newest_bugs(amount):
|
||
|
# result = server.newest_bugs(amount)
|
||
|
# return result
|
||
|
#
|
||
|
#if __name__ == "__main__":
|
||
|
# # Demonstration
|
||
|
#
|
||
|
# # some debug output
|
||
|
#
|
||
|
# # All bugs from one package (returns a list of bugnumbers)
|
||
|
# print get_bugs("package", "gtk-qt-engine")
|
||
|
#
|
||
|
# # All bugs of a maintainer
|
||
|
# print get_bugs("maint", "debian-qa@lists.debian.org")
|
||
|
#
|
||
|
# # returns the status of those bugs
|
||
|
# print get_status(409909, 419920, 421581, 417044, 397993)
|
||
|
#
|
||
|
# # get_status and get_bugs combined:
|
||
|
# print get_status(get_bugs("package", "gtk-qt-engine"))
|
||
|
#
|
||
|
# # returns the full log for the given bug number
|
||
|
# print get_bug_log(202526)
|
||
|
#
|
||
|
# # retrives the newest 20 bugs
|
||
|
# print newest_bugs(20)
|
||
|
#
|
||
|
# # All bugs of a maintainer
|
||
|
# print get_bugs("maint", "debian-qa@lists.debian.org")
|
||
|
#
|
||
|
# # returns the status of those bugs
|
||
|
# print get_status(409909, 419920, 421581, 417044, 397993)
|
||
|
#
|
||
|
# # get_status and get_bugs combined:
|
||
|
# print get_status(get_bugs("package", "gtk-qt-engine"))
|
||
|
#
|
||
|
# # returns the full log for the given bug number
|
||
|
# print get_bug_log(202526)
|
||
|
#
|
||
|
# # retrives the newest 20 bugs
|
||
|
# print newest_bugs(20)
|
||
|
#
|
||
|
# # returns bugs tagged by the given email
|
||
|
# print get_usertag("debian-qa@lists.debian.org")
|
||
|
#
|
||
|
# # returns bugs tagged by the given email, with the given tag
|
||
|
# print get_usertag("debian-qa@lists.debian.org", "qa-ftbfs-20070708")
|
||
|
#
|