Created
March 29, 2012 20:16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# File needs-packaging bugs with the given information | |
# | |
# Copyright (C) 2012 Philip Muskovac <yofel@kubuntu.org> | |
# | |
# 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, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# 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. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
# | |
############################################################################## | |
## SPEC | |
## needed: | |
## package, version, description, tags, title | |
## | |
## possibly: | |
## status and someone to assign | |
## | |
## which tags to use? | |
## kubuntu + needs-packaging | |
## kubuntu + needs-packaging/upgrade-software-version | |
## k-needs-packaging | |
import sys | |
from lazr.restfulclient.errors import HTTPError | |
from optparse import OptionParser | |
from launchpadlib.launchpad import Launchpad | |
parser = OptionParser("%prog [-n] <package> <version> [description]") | |
parser.add_option('-n', '--new', dest='new', action='store_true', | |
help="This is a new package which isn't yet in the archive.") | |
(options, args) = parser.parse_args() | |
if len(args) < 2: | |
pass | |
# TODO: get the parameters Interactively | |
package = None | |
version = "1.0" | |
else: | |
package = args[0] | |
version = args[1] | |
if len(args) > 2: | |
description = ' '.join(args[2:]) | |
else: | |
description = None | |
lp = Launchpad.login_with('newpackage', 'production', credentials_file="/home/yofel/.cache/lp_credentials/creds.txt") | |
ubuntu = lp.distributions["ubuntu"] | |
source = ubuntu.getSourcePackage(name=package) | |
try: | |
if source and (not options.new): | |
d = "%s needs to be updated to %s" % (package, version) | |
if description: | |
d += '\n' + description | |
t = "Please update %s to %s" % (package, version) | |
bug = lp.bugs.createBug(description=d, tags=['upgrade-software-version', 'kubuntu', 'kubuntu-packaging'], | |
target=source, title=t) | |
elif options.new and (not source): | |
d = "Please package %s %s" % (package, version) | |
if description: | |
d += '\n' + description | |
# TODO: What to do with the source and license info? | |
t = "[needs-packaging] " + package | |
bug = lp.bugs.createBug(description=d, tags=['needs-packaging', 'kubuntu', 'kubuntu-packaging'], | |
target=ubuntu, title=t) | |
# subscribe kubuntu-bugs so we have a place we can follow it | |
bug.subscribe(person=lp.people['kubuntu-bugs']) | |
elif (not source) and (not options.new): | |
print("Package %s doesn't exist yet!" % package) | |
sys.exit(2) | |
elif options.new and source: | |
print("Package %s already exists!" % package) | |
sys.exit(3) | |
except HTTPError, e: | |
print("HTTPError: " + e.content) | |
sys.exit(1) | |
# Set the importance to wishlist if the permissions allow it | |
try: | |
bugtask = bug.bug_tasks[0] | |
bugtask.importance = 'Wishlist' | |
bugtask.lp_save() | |
except HTTPError, e: | |
pass # Couldn't not set importance -> nevermind. | |
except: | |
raise | |
# return a link to the created bug | |
print(bug.web_link) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment