mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
requestsync: move post_bug() to ubuntutools/requestsync/lp.py
This commit is contained in:
parent
7ff9aa777a
commit
d96e4af643
48
requestsync
48
requestsync
@ -41,6 +41,7 @@ import ubuntutools.common
|
||||
|
||||
from ubuntutools.requestsync.mail import *
|
||||
from ubuntutools.requestsync.common import *
|
||||
from ubuntutools.requestsync.lp import postBug
|
||||
|
||||
def checkExistingReports(package):
|
||||
""" Check existing bug reports on Launchpad for a possible sync request.
|
||||
@ -199,51 +200,6 @@ Content-Type: text/plain; charset=UTF-8
|
||||
|
||||
return True
|
||||
|
||||
def post_bug(source_package, subscribe, status, bugtitle, bugtext):
|
||||
'''Use python-launchpadlib to submit the sync request.
|
||||
Return True if successfully posted, otherwise False.'''
|
||||
|
||||
import glob, os.path
|
||||
|
||||
try:
|
||||
launchpad = Launchpad.login()
|
||||
except ImportError:
|
||||
print >> sys.stderr, 'Importing launchpadlib failed. Is python-launchpadlib installed?'
|
||||
return False
|
||||
except IOError, msg:
|
||||
# No credentials found.
|
||||
print msg
|
||||
sys.exit(1)
|
||||
|
||||
if source_package:
|
||||
product_url = "%subuntu/+source/%s" %(launchpad._root_uri, source_package)
|
||||
else:
|
||||
# new source package
|
||||
product_url = "%subuntu" %launchpad._root_uri
|
||||
|
||||
print 'Summary:\n%s\n\nDescription:\n%s' % (bugtitle, bugtext)
|
||||
|
||||
# ask for confirmation and allow to edit:
|
||||
print 'Do you want to edit the report before sending [y/N]? Press Control-C to abort.'
|
||||
raw_input_exit_on_ctrlc()
|
||||
|
||||
# Create bug
|
||||
bug = launchpad.bugs.createBug(description=bugtext, title=bugtitle, target=product_url)
|
||||
|
||||
#newly created bugreports have 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()
|
||||
|
||||
subscribe_url = "%s~%s" %(launchpad._root_uri, subscribe)
|
||||
bug.subscribe(person=subscribe_url)
|
||||
|
||||
print 'Sync request filed as bug #%i: %s' % (bug.id,
|
||||
lp_libsupport.translate_api_web(bug.self_link))
|
||||
return True
|
||||
|
||||
#
|
||||
# entry point
|
||||
@ -405,7 +361,7 @@ if __name__ == '__main__':
|
||||
if use_lp_bugs:
|
||||
# Map status to the values expected by lp-bugs
|
||||
mapping = {'new': 'New', 'confirmed': 'Confirmed'}
|
||||
if post_bug(srcpkg, subscribe, mapping[status], title, report):
|
||||
if postBug(srcpkg, subscribe, mapping[status], title, report):
|
||||
sys.exit(0)
|
||||
# Abort on error:
|
||||
print 'Something went wrong. No sync request filed.'
|
||||
|
@ -21,8 +21,9 @@
|
||||
# of the GNU General Public License license.
|
||||
|
||||
from .common import raw_input_exit_on_ctrlc
|
||||
from ..lp.lpapiwrapper import Distribution, PersonTeam
|
||||
from ..lp.lpapiwrapper import Launchpad, Distribution, PersonTeam, DistributionSourcePackage
|
||||
from ..lp.udtexceptions import *
|
||||
from ..lp.lp_libsupport import translate_api_web
|
||||
|
||||
def getDebianSrcPkg(name, release):
|
||||
debian = Distribution('debian')
|
||||
@ -54,6 +55,37 @@ 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.'''
|
||||
raw_input_exit_on_ctrlc('If the above is correct please press [Enter]: '
|
||||
raw_input_exit_on_ctrlc('If the above is correct please press [Enter]: ')
|
||||
|
||||
return need_sponsor
|
||||
|
||||
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)
|
||||
raw_input_exit_on_ctrlc('Press [Enter] to continue and [Ctrl-C] to abort. ')
|
||||
|
||||
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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user