~ubuntu-bugcontrol/ubuntu-qa-tools/master

« back to all changes in this revision

Viewing changes to responses/security/reassign.py

  • Committer: Steve Beattie
  • Date: 2017-10-10 05:31:30 UTC
  • Revision ID: sbeattie@ubuntu.com-20171010053130-ufiha14x7bvp94db
Inform people that the repo has converted to git and the bzr branch will no longer be updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# Copyright (C) 2007-2008 Canonical, Ltd.
3
 
# Author: Kees Cook <kees@ubuntu.com>
4
 
# License: GPLv3
5
 
import sys, os
6
 
import lpl_common
7
 
import re
8
 
 
9
 
def set_status(task, package, targeted_to, status):
10
 
    if status != "-" and task.status != status:
11
 
        print '%s,%s: status => %s' % (package,targeted_to,status)
12
 
        task.status=status
13
 
        lpl_common.save(task)
14
 
 
15
 
def set_importance(task, package, targeted_to, importance):
16
 
    if importance != "-" and task.importance != importance:
17
 
        print '%s,%s: importance => %s' % (package,targeted_to,importance)
18
 
        task.importance=importance
19
 
        lpl_common.save(task)
20
 
 
21
 
def set_assignee(task, package, targeted_to, assignee):
22
 
    if assignee and task.assignee != assignee:
23
 
        print '%s,%s: assignee => %s' % (package,targeted_to,assignee)
24
 
        task.assignee=assignee
25
 
        lpl_common.save(task)
26
 
 
27
 
if len(sys.argv) < 6:
28
 
    print 'Usage: reassign.py PKG STATUS IMPORTANCE ASSIGNEE TARGET bug [bug ...]'
29
 
    print '  Required arguments can be "-" to leave a field unchanged.'
30
 
    sys.exit(1)
31
 
 
32
 
pkg = sys.argv[1]
33
 
status = " ".join( [x.capitalize() for x in sys.argv[2].split(' ')] )
34
 
valid_status = ['New','Invalid','Fix Released','Fix Committed','Incomplete',"Won't Fix",'Confirmed','Triaged','In Progress','-']
35
 
if status not in valid_status:
36
 
    raise ValueError, 'Status must be one of "'+'", "'.join(valid_status)
37
 
 
38
 
importance = sys.argv[3]
39
 
if importance not in ['Critical','High','Medium','Low','Wishlist','-']:
40
 
    raise ValueError, "Invalid Importance"
41
 
 
42
 
launchpad = lpl_common.connect()
43
 
 
44
 
assignee = None
45
 
if sys.argv[4] != 'None' and sys.argv[4] != '-':
46
 
    assignee = launchpad.people[sys.argv[4]]
47
 
 
48
 
target_releases = []
49
 
if sys.argv[5] != None and sys.argv[5] != '-':
50
 
    target_releases = re.split(',', sys.argv[5].lower())
51
 
 
52
 
for num in sys.argv[6:]:
53
 
    bug = launchpad.bugs[num]
54
 
    none_list = []
55
 
    nominated_list = []
56
 
 
57
 
    for task in bug.bug_tasks:
58
 
        package, target, targeted_to = lpl_common.extract_task(task)
59
 
 
60
 
        #print "package:%s targeted_to:%s" % (package, targeted_to)
61
 
 
62
 
        if target and target.lower() != 'ubuntu':
63
 
            print 'skipping target "%s" (%s)' % (target, package)
64
 
            continue
65
 
        if task.status in ['Fix Released', 'Incomplete', 'Invalid', "Won't Fix"]:
66
 
            print 'skipping (pkg:%s targeted_to:%s status:%s)' % (package, targeted_to, task.status)
67
 
            continue
68
 
        if len(target_releases) > 0 and targeted_to not in target_releases:
69
 
            print 'skipping (pkg:%s targeted_to:%s target_releases:%s)' % (package, targeted_to, target_releases)
70
 
            continue
71
 
        if pkg == "-" or package == pkg:
72
 
            # keep track of these for later
73
 
            if targeted_to == None:
74
 
                none_list.append(package)
75
 
                print 'delaying processing (pkg:%s targeted_to:%s)' % (package, targeted_to)
76
 
                continue
77
 
            else:
78
 
                nominated_list.append(package)
79
 
 
80
 
            #print "checking %s,%s: %s %s %s" % (package, targeted_to, task.status, task.importance, task.assignee)
81
 
            set_status(task,package,targeted_to,status)
82
 
            set_importance(task,package,targeted_to,importance)
83
 
            set_assignee(task,package,targeted_to,assignee)
84
 
        else:
85
 
            print 'skipping package "%s"' % (package)
86
 
 
87
 
    # process bugs that don't have a targeted_to and don't have nominations
88
 
    for p in none_list:
89
 
        if p in nominated_list:
90
 
            print 'skipping (pkg:%s has nominations)' % (p)
91
 
        else:
92
 
            for task in bug.bug_tasks:
93
 
                package = None
94
 
                targeted_to = None
95
 
                target = None
96
 
                package, target, targeted_to = lpl_common.extract_task(task)
97
 
                if (pkg == "-" or pkg == p) and p == package:
98
 
                    set_status(task,package,targeted_to,status)
99
 
                    set_importance(task,package,targeted_to,importance)
100
 
                    set_assignee(task,package,targeted_to,assignee)
101