2007-09-27 11:09:42 +02:00
|
|
|
#!/usr/bin/python
|
2007-11-07 20:05:37 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2007-09-27 11:09:42 +02:00
|
|
|
#
|
2008-08-11 20:06:35 +02:00
|
|
|
# Copyright (C) 2007 Canonical Ltd.
|
2008-08-04 20:51:47 +02:00
|
|
|
#
|
|
|
|
# Modified by Iain Lane <iain@orangesquash.org.uk>, taking some code written by
|
|
|
|
# Daniel Hahler <ubuntu@thequod.de>
|
2008-08-11 20:06:35 +02:00
|
|
|
#
|
2009-01-19 18:10:53 +00:00
|
|
|
# python-launchpadlib support was added by Markus Korn <thekorn@gmx.de>.
|
|
|
|
#
|
2008-08-11 20:06:35 +02:00
|
|
|
# ##################################################################
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; version 3.
|
2010-12-03 00:06:43 +01:00
|
|
|
#
|
2008-08-11 20:06:35 +02:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# See file /usr/share/common-licenses/GPL-3 for more details.
|
|
|
|
#
|
|
|
|
# ##################################################################
|
2007-09-27 09:44:58 +02:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import email
|
2007-09-27 09:44:58 +02:00
|
|
|
|
2009-01-19 22:37:27 +00:00
|
|
|
from ubuntutools.lp.libsupport import get_launchpad, translate_api_web, translate_web_api
|
2007-09-27 09:44:58 +02:00
|
|
|
|
|
|
|
def read_config():
|
2007-09-27 11:09:42 +02:00
|
|
|
instructions_file = open("instructions")
|
|
|
|
instructions = email.message_from_file(instructions_file)
|
|
|
|
instructions_file.close()
|
|
|
|
instr = dict()
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
for field in "subject", "assignee", "subscribers", "tags", "text", \
|
2008-08-04 20:51:47 +02:00
|
|
|
"buglist-url", "status":
|
2007-09-27 11:09:42 +02:00
|
|
|
instr[field] = instructions.get(field)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
return instr
|
2007-09-27 09:44:58 +02:00
|
|
|
|
|
|
|
def read_list():
|
2007-09-27 11:09:42 +02:00
|
|
|
pack_list = set()
|
2007-09-27 09:44:58 +02:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
listfile = open("list")
|
|
|
|
for line in listfile.readlines():
|
|
|
|
if line.strip()!="":
|
|
|
|
pack_list.add(line.strip("\n"))
|
2007-09-27 09:44:58 +02:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
listfile.close()
|
|
|
|
return pack_list
|
|
|
|
|
|
|
|
def check_configfiles():
|
|
|
|
result = True
|
|
|
|
|
2007-09-27 11:44:42 +02:00
|
|
|
bin_path = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
if bin_path == "/usr/bin":
|
2007-09-27 11:49:05 +02:00
|
|
|
example_dir = "/usr/share/doc/ubuntu-dev-tools/examples"
|
2007-09-27 11:44:42 +02:00
|
|
|
else:
|
2007-09-27 11:49:05 +02:00
|
|
|
example_dir = "%s/examples" % bin_path
|
2007-09-27 11:44:42 +02:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
if not os.path.exists("instructions"):
|
|
|
|
os.system("cp %s/massfile.instructions instructions" % example_dir)
|
|
|
|
print >> sys.stderr, \
|
|
|
|
"No 'instructions' file found. Copied template from %s." % \
|
|
|
|
example_dir
|
|
|
|
result = False
|
|
|
|
|
|
|
|
if not os.path.exists("list"):
|
|
|
|
os.system("cp %s/massfile.list list" % example_dir)
|
|
|
|
print >> sys.stderr, \
|
|
|
|
"No 'list' file found. Copied template from %s." % example_dir
|
|
|
|
result = False
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def file_bug(config):
|
2009-01-05 14:45:53 +01:00
|
|
|
launchpad = get_launchpad("ubuntu-dev-tools")
|
2007-09-27 11:09:42 +02:00
|
|
|
|
2007-09-27 12:03:30 +02:00
|
|
|
try:
|
2007-09-27 12:17:12 +02:00
|
|
|
summary = config["subject"].replace("$pack", config["sourcepackage"])
|
|
|
|
description = config["text"].replace("$pack", config["sourcepackage"])
|
2009-01-05 14:45:53 +01:00
|
|
|
|
|
|
|
product_url = "%subuntu/+source/%s" %(launchpad._root_uri, config["sourcepackage"])
|
|
|
|
tags = filter(None, map(lambda t: t.strip("\n").strip(), config["tags"].split(",")))
|
|
|
|
bug = launchpad.bugs.createBug(description=description, title=summary,
|
|
|
|
target=product_url, tags=tags)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
print "Successfully filed bug %i: %s" %(bug.id, translate_api_web(bug.self_link))
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
subscribers = filter(None, map(lambda t: t.strip("\n").strip(), config["subscribers"].split(",")))
|
|
|
|
for sub in subscribers:
|
|
|
|
subscribe_url = "%s~%s" %(launchpad._root_uri, sub)
|
|
|
|
bug.subscribe(person=subscribe_url)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
#newly created bugreports have one task
|
|
|
|
task = bug.bug_tasks[0]
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2008-08-04 20:51:47 +02:00
|
|
|
if config["status"]:
|
2009-01-05 14:45:53 +01:00
|
|
|
status = config["status"].capitalize()
|
2008-08-04 20:51:47 +02:00
|
|
|
else:
|
2009-01-05 14:45:53 +01:00
|
|
|
status = "Confirmed"
|
2010-03-20 18:27:31 +01:00
|
|
|
task.status = status
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
assignee = config["assignee"]
|
|
|
|
if assignee:
|
|
|
|
assignee_url = "%s~%s" %(launchpad._root_uri, assignee)
|
2010-03-20 18:27:31 +01:00
|
|
|
task.assignee = assignee_url
|
|
|
|
task.lp_save()
|
2007-09-27 12:03:30 +02:00
|
|
|
except:
|
|
|
|
"Bug for '%s' was not filed." % config["sourcepackage"]
|
2007-09-27 11:09:42 +02:00
|
|
|
|
|
|
|
def read_buglist(url):
|
2009-01-05 14:45:53 +01:00
|
|
|
if not url:
|
|
|
|
return set()
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
if len(url.split("?", 1)) == 2:
|
|
|
|
# search options not supported, because there is no mapping web ui options <-> API options
|
|
|
|
print >> sys.stderr, "Options in url are not supported, url: %s" %url
|
|
|
|
sys.exit(1)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
launchpad = get_launchpad("ubuntu-dev-tools")
|
2007-09-27 11:09:42 +02:00
|
|
|
packages = set()
|
2007-09-27 11:49:05 +02:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
api_url = translate_web_api(url, launchpad)
|
|
|
|
# workaround LP #303414
|
|
|
|
# if this is fixed it should simply be: buglist = launchpad.load(api_url)
|
|
|
|
api_url = api_url.split("?", 1)[0]
|
|
|
|
project = launchpad.load(api_url)
|
|
|
|
buglist = project.searchTasks()
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2009-01-05 14:45:53 +01:00
|
|
|
for bug in buglist:
|
|
|
|
packages.add(bug.bug_target_name)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
return packages
|
2008-08-04 20:51:47 +02:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
def main():
|
|
|
|
if not check_configfiles():
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
config = read_config()
|
|
|
|
pack_list = read_list()
|
|
|
|
buglist = read_buglist(config["buglist-url"])
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
for pack in pack_list:
|
|
|
|
if pack not in buglist:
|
|
|
|
config["sourcepackage"] = pack
|
|
|
|
file_bug(config)
|
|
|
|
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2007-09-27 11:09:42 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
2007-09-27 09:44:58 +02:00
|
|
|
|