/[qa]/trunk/pts/www/bin/tagged_bugs.py
ViewVC logotype

Contents of /trunk/pts/www/bin/tagged_bugs.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2021 - (show annotations) (download) (as text)
Mon Nov 3 17:15:44 2008 UTC (4 years, 6 months ago) by zack
File MIME type: text/x-python
File size: 2129 byte(s)
ensure spaces do not end up in package/bugcount indexes
1 #!/usr/bin/python
2
3 # Copyright 2008 Stefano Zacchiroli <zack@debian.org>
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6
7 # Script to collect bug summaries from the Debian BTS via SOAP.
8 # Lookup can be performed via official tags or via usertags.
9
10 import SOAPpy
11 import string
12 import sys
13
14 url = 'http://bugs.debian.org/cgi-bin/soap.cgi'
15 namespace = 'Debbugs/SOAP'
16 server = SOAPpy.SOAPProxy(url, namespace)
17
18 def get_usertag(email, *tags):
19 result = server.get_usertag(email, *tags)
20 return result
21
22 def get_status(*args):
23 result = server.get_status(*args)
24 return result
25
26 def get_bugs(*args):
27 result = server.get_bugs(*args)
28 return result
29
30 def mk_summary(bugs):
31 pkgs = {} # map package names to list of gift bug numbers
32 statuses = get_status(bugs)
33 i = 0
34 for status in statuses[0]:
35 if status['value']['done'] or status['value']['fixed'] or \
36 status['value']['pending'] == 'fixed':
37 # roughly equivalent to filtering via Debbugs URL snippet
38 # pend-exc=pending-fixed&pend-exc=fixed&pend-exc=done
39 continue
40 pkg = status['value']['package']
41 if not pkgs.has_key(pkg):
42 pkgs[pkg] = []
43 pkgs[pkg].append(str(bugs[i]))
44 i += 1
45 return pkgs
46
47 def find_usertagged(user, tag):
48 bugs = get_usertag(user, tag)
49 return mk_summary(bugs[0])
50
51 def find_tagged(tag):
52 bugs = get_bugs('tag', tag)
53 return mk_summary(bugs)
54
55 if __name__ == '__main__':
56
57 def print_bug_summary(dict):
58 for (pkg, bugs) in dict.iteritems():
59 pkg = string.replace(pkg, ' ', '') # ensure spaces do not occur
60 # between packages
61 print "%s\t%d" % (pkg, len(bugs))
62
63 if len(sys.argv) == 1 or len(sys.argv) > 3:
64 print 'Usage: tagged_bugs.py TAG [USER]'
65 sys.exit(2)
66 elif len(sys.argv) == 2:
67 print_bug_summary(find_tagged(sys.argv[1]))
68 elif len(sys.argv) == 3:
69 print_bug_summary(find_usertagged(sys.argv[2], sys.argv[1]))
70

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5