~xnox/ubuntu-archive-tools/sru-report-autopkgtest-vomit

« back to all changes in this revision

Viewing changes to sru-review

  • Committer: Łukasz 'sil2100' Zemczak
  • Date: 2017-11-20 16:33:04 UTC
  • mto: This revision was merged to the branch mainline in revision 1132.
  • Revision ID: lukasz.zemczak@canonical.com-20171120163304-oekn0evfycwu7kz1
Extract the process_bug() function to a common module so that both sru-review and sru-accept use the same mechanics for updating SRU bugs after acceptance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
import webbrowser
44
44
 
45
45
from launchpadlib.launchpad import Launchpad
 
46
from sru_workflow import process_bug
46
47
from time import sleep
47
48
 
48
49
 
245
246
                   subject='Proposed package upload rejected')
246
247
 
247
248
 
248
 
def process_bug(launchpad, upload, num):
249
 
    bug_target_re = re.compile(
250
 
        r'/ubuntu/(?:(?P<suite>[^/]+)/)?\+source/(?P<source>[^/]+)$')
251
 
    bug = launchpad.bugs[num]
252
 
    sourcepkg = upload.package_name
253
 
    release = upload.distroseries.name
254
 
    sourcepkg_match = False
255
 
    distroseries_match = False
256
 
    for task in bug.bug_tasks:
257
 
        # Ugly; we have to do URL-parsing to figure this out.
258
 
        # /ubuntu/+source/foo can be fed to launchpad.load() to get a
259
 
        # distribution_source_package, but /ubuntu/hardy/+source/foo can't.
260
 
        match = bug_target_re.search(task.target.self_link)
261
 
        if (not match or
262
 
            (sourcepkg and
263
 
             match.group('source') != sourcepkg)):
264
 
            print("Ignoring task %s in bug %s" % (task.web_link, num))
265
 
            continue
266
 
        sourcepkg_match = True
267
 
        if (match.group('suite') == release and
268
 
            task.status not in ("Invalid", "Won't Fix",
269
 
                                "Fix Released")):
270
 
            task.status = "Fix Committed"
271
 
            task.lp_save()
272
 
            print("Success: task %s in bug %s" % (task.web_link, num))
273
 
            distroseries_match = True
274
 
 
275
 
    if sourcepkg_match and not distroseries_match:
276
 
        # add a release task
277
 
        lp_url = launchpad._root_uri
278
 
        series_task_url = '%subuntu/%s/+source/%s' % \
279
 
                          (lp_url, release, sourcepkg)
280
 
        sourcepkg_target = launchpad.load(series_task_url)
281
 
        new_task = bug.addTask(target=sourcepkg_target)
282
 
        new_task.status = "Fix Committed"
283
 
        new_task.lp_save()
284
 
        print("LP: #%s added task for %s %s" % (num, sourcepkg, release))
285
 
    if not sourcepkg_match:
286
 
        # warn that the bug has no source package tasks
287
 
        print("LP: #%s has no %s tasks!" % (num, sourcepkg))
288
 
 
289
 
    # XXX: it might be useful if the package signer/sponsor was
290
 
    #   subscribed to the bug report
291
 
    bug.subscribe(person=launchpad.people['ubuntu-sru'])
292
 
    bug.subscribe(person=launchpad.people['sru-verification'])
293
 
 
294
 
    # there may be something else to sponsor so just warn
295
 
    subscribers = [sub.person for sub in bug.subscriptions]
296
 
    if launchpad.people['ubuntu-sponsors'] in subscribers:
297
 
        print('ubuntu-sponsors is still subscribed to LP: #%s. '
298
 
              'Is there anything left to sponsor?' % num)
299
 
 
300
 
    if not sourcepkg or 'linux' not in sourcepkg:
301
 
        # this dance is needed due to
302
 
        # https://bugs.launchpad.net/launchpadlib/+bug/254901
303
 
        btags = bug.tags
304
 
        for t in ('verification-failed', 'verification-failed-%s' % release,
305
 
                  'verification-done', 'verification-done-%s' % release):
306
 
            if t in btags:
307
 
                tags = btags
308
 
                tags.remove(t)
309
 
                bug.tags = tags
310
 
 
311
 
        if 'verification-needed' not in btags:
312
 
            btags.append('verification-needed')
313
 
            bug.tags = btags
314
 
 
315
 
        needed_tag = 'verification-needed-%s' % release
316
 
        if needed_tag not in btags:
317
 
            btags.append(needed_tag)
318
 
            bug.tags = btags
319
 
 
320
 
        bug.lp_save()
321
 
 
322
 
 
323
 
    text = ('Hello %s, or anyone else affected,\n\n' %
324
 
            re.split(r'[,\s]', bug.owner.display_name)[0])
325
 
 
326
 
    if sourcepkg:
327
 
        text += 'Accepted %s into ' % sourcepkg
328
 
    else:
329
 
        text += 'Accepted into '
330
 
    if sourcepkg and release:
331
 
        text += ('%s-proposed. The package will build now and be available at '
332
 
                 'https://launchpad.net/ubuntu/+source/%s/%s in a few hours, '
333
 
                 'and then in the -proposed repository.\n\n' % (
334
 
                     release, sourcepkg, upload.package_version))
335
 
    else:
336
 
        text += ('%s-proposed. The package will build now and be available in '
337
 
                 'a few hours in the -proposed repository.\n\n' % (
338
 
                     release))
339
 
 
340
 
    text += ('Please help us by testing this new package.  ')
341
 
 
342
 
    if sourcepkg == 'casper':
343
 
        text += ('To properly test it you will need to obtain and boot '
344
 
                 'a daily build of a Live CD for %s.' % (release))
345
 
    else:
346
 
        text += ('See https://wiki.ubuntu.com/Testing/EnableProposed for '
347
 
                 'documentation on how to enable and use -proposed.')
348
 
 
349
 
    text += ('Your feedback will aid us getting this update out to other '
350
 
             'Ubuntu users.\n\nIf this package fixes the bug for you, '
351
 
             'please add a comment to this bug, mentioning the version of the '
352
 
             'package you tested and change the tag from '
353
 
             'verification-needed-%s to verification-done-%s. '
354
 
             'If it does not fix the bug for you, please add a comment '
355
 
             'stating that, and change the tag to verification-failed-%s. In '
356
 
             'either case, details of your testing will help us make a better '
357
 
             'decision.\n\nFurther information regarding the verification '
358
 
             'process can be found at '
359
 
             'https://wiki.ubuntu.com/QATeam/PerformingSRUVerification .  '
360
 
             'Thank you in advance!' % (release, release, release))
361
 
    bug.newMessage(content=text, subject='Please test proposed package')
362
 
 
363
 
 
364
249
if __name__ == '__main__':
365
250
 
366
251
    default_release = 'artful'
472
357
        print("Accepted")
473
358
        if changes['bugs']:
474
359
            for bug_num in changes['bugs']:
475
 
                process_bug(launchpad, upload, bug_num)
 
360
                process_bug(
 
361
                    launchpad, upload.package_name, upload.package_version,
 
362
                    upload.distroseries.name, bug_num)
476
363
    else:
477
364
        print("REJECT the package from -proposed? [yN] ", end="")
478
365
        response = sys.stdin.readline()