1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/usr/bin/python
import sys
import apport
from apport.crashdb import get_crashdb
from launchpadlib.launchpad import Launchpad
def match_bug(bugnumber):
db = get_crashdb(None)
report = db.download(bugnumber)
match = report.search_bug_patterns('bugpatterns.xml')
if match:
print 'LP: #%s: Matched bug pattern: %s' % (bugnumber, match )
else:
print 'LP: #%s: No match' % bugnumber
lp = Launchpad.login_anonymously('apport', 'production')
if len(sys.argv) != 2:
print >> sys.stderr, 'Usage: %s <.crash file or bug number>' % sys.argv[0]
sys.exit(1)
if not sys.argv[1].isdigit():
report = apport.Report()
try:
f = open(sys.argv[1])
except IOError, e:
print >> sys.stderr, 'Cannot open report file: %s' % str(e)
sys.exit(1)
report.load(f)
f.close()
match = report.search_bug_patterns('bugpatterns.xml')
if match:
print 'LP: #%s: Matched bug pattern: %s' % ( sys.argv[1], match )
sys.exit(0)
else:
print 'LP: #%s: No match' % sys.argv[1]
sys.exit(1)
else:
match_bug(sys.argv[1])
bug = lp.bugs[sys.argv[1]]
# if bug is a duplicate - call this for parent
if bug.duplicate_of:
dupe = bug.duplicate_of.id
print 'LP: #%s is a duplicate of ....' % bug.id
match_bug(dupe)
if bug.duplicates:
print "Checking duplicate bugs..."
for duplicate in bug.duplicates:
# Skip if not an apport bug
if 'apport-crash' in duplicate.tags or \
'apport-package' in duplicate.tags or \
'apport-bug' in duplicate.tags:
match_bug(duplicate.id)
sys.exit(0)
|