2009-08-04 13:43:31 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# lp.py - methods used by requestsync while interacting
|
|
|
|
# directly with Launchpad
|
|
|
|
#
|
|
|
|
# Copyright © 2009 Michael Bienia <geser@ubuntu.com>
|
|
|
|
#
|
2009-08-05 23:10:05 +02:00
|
|
|
# This module may contain code written by other authors/contributors to
|
|
|
|
# the main requestsync script. See there for their names.
|
|
|
|
#
|
2009-08-04 13:43:31 +02:00
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
2009-08-05 23:10:05 +02:00
|
|
|
# as published by the Free Software Foundation; version 2
|
2009-08-04 13:43:31 +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.
|
|
|
|
#
|
2009-08-05 23:10:05 +02:00
|
|
|
# Please see the /usr/share/common-licenses/GPL-2 file for the full text
|
2009-08-04 13:43:31 +02:00
|
|
|
# of the GNU General Public License license.
|
|
|
|
|
2009-08-07 14:07:46 +02:00
|
|
|
from .common import raw_input_exit_on_ctrlc
|
2009-08-12 13:46:21 +02:00
|
|
|
from ..lp.lpapiwrapper import Launchpad, Distribution, PersonTeam, DistributionSourcePackage
|
2009-08-04 13:43:31 +02:00
|
|
|
from ..lp.udtexceptions import *
|
2009-08-12 13:46:21 +02:00
|
|
|
from ..lp.lp_libsupport import translate_api_web
|
2009-08-04 13:43:31 +02:00
|
|
|
|
|
|
|
def getDebianSrcPkg(name, release):
|
|
|
|
debian = Distribution('debian')
|
|
|
|
debian_archive = debian.getArchive()
|
|
|
|
|
|
|
|
# Map 'unstable' to 'sid' as LP doesn't know 'unstable' but only 'sid'
|
|
|
|
if release == 'unstable':
|
|
|
|
release = 'sid'
|
|
|
|
|
|
|
|
return debian_archive.getSourcePackage(name, release)
|
2009-08-06 00:23:58 +02:00
|
|
|
|
|
|
|
def getUbuntuSrcPkg(name, release):
|
|
|
|
ubuntu = Distribution('ubuntu')
|
|
|
|
ubuntu_archive = ubuntu.getArchive()
|
|
|
|
|
|
|
|
return ubuntu_archive.getSourcePackage(name, release)
|
2009-08-07 14:07:46 +02:00
|
|
|
|
|
|
|
def needSponsorship(name, component):
|
|
|
|
'''
|
|
|
|
Check if the user has upload permissions for either the package
|
|
|
|
itself or the component
|
|
|
|
'''
|
|
|
|
archive = Distribution('ubuntu').getArchive()
|
|
|
|
|
|
|
|
need_sponsor = not PersonTeam.getMe().canUploadPackage(archive, name, component)
|
|
|
|
if need_sponsor:
|
|
|
|
print '''You are not able to upload this package directly to Ubuntu.
|
|
|
|
Your sync request shall require an approval by a member of the appropriate
|
|
|
|
sponsorship team, who shall be subscribed to this bug report.
|
|
|
|
This must be done before it can be processed by a member of the Ubuntu Archive
|
|
|
|
team.'''
|
2009-08-12 13:46:21 +02:00
|
|
|
raw_input_exit_on_ctrlc('If the above is correct please press [Enter]: ')
|
2009-08-07 14:07:46 +02:00
|
|
|
|
|
|
|
return need_sponsor
|
2009-08-12 13:46:21 +02:00
|
|
|
|
|
|
|
def postBug(srcpkg, subscribe, status, bugtitle, bugtext):
|
|
|
|
'''
|
|
|
|
Use the LP API to file the sync request.
|
|
|
|
'''
|
|
|
|
|
|
|
|
print 'The final report is:\nSummary: %s\nDescription:\n%s\n' % (bugtitle, bugtext)
|
2009-08-22 11:59:22 +02:00
|
|
|
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
|
2009-08-12 13:46:21 +02:00
|
|
|
|
|
|
|
if srcpkg:
|
|
|
|
bug_target = DistributionSourcePackage(
|
|
|
|
'%subuntu/+source/%s' % (Launchpad._root_uri, srcpkg))
|
|
|
|
else:
|
|
|
|
# new source package
|
|
|
|
bug_target = Distribution('ubuntu')
|
|
|
|
|
|
|
|
# create bug
|
|
|
|
bug = Launchpad.bugs.createBug(title = bugtitle, description = bugtext, target = bug_target)
|
|
|
|
|
|
|
|
# newly created bugreports have only one task
|
|
|
|
task = bug.bug_tasks[0]
|
|
|
|
# only members of ubuntu-bugcontrol can set importance
|
|
|
|
if PersonTeam.getMe().isLpTeamMember('ubuntu-bugcontrol'):
|
|
|
|
task.importance = 'Wishlist'
|
|
|
|
task.status = status
|
|
|
|
task.lp_save()
|
|
|
|
|
|
|
|
bug.subscribe(person = PersonTeam(subscribe))
|
|
|
|
|
|
|
|
print 'Sync request filed as bug #%i: %s' % (bug.id,
|
|
|
|
translate_api_web(bug.self_link))
|