summaryrefslogtreecommitdiffstats
path: root/scripts/abrt-bz-downloader
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/abrt-bz-downloader')
-rwxr-xr-xscripts/abrt-bz-downloader82
1 files changed, 82 insertions, 0 deletions
diff --git a/scripts/abrt-bz-downloader b/scripts/abrt-bz-downloader
new file mode 100755
index 00000000..7f294257
--- /dev/null
+++ b/scripts/abrt-bz-downloader
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+# -*- mode:python -*-
+# ABRT Bugzilla Backtrace Downloader
+# Downloads all backtraces reported by ABRT from Bugzilla.
+#
+# Please do not run this script unless it's neccessary to do so.
+# It forces Bugzilla to send data related to thousands of bug reports.
+
+from bugzilla import RHBugzilla
+from optparse import OptionParser
+import sys
+import os.path
+
+parser = OptionParser(version="%prog 1.0")
+parser.add_option("-u", "--user", dest="user",
+ help="Bugzilla user name (REQUIRED)", metavar="USERNAME")
+parser.add_option("-p", "--password", dest="password",
+ help="Bugzilla password (REQUIRED)", metavar="PASSWORD")
+parser.add_option("-b", "--bugzilla", dest="bugzilla",
+ help="Bugzilla URL (defaults to Red Hat Bugzilla)", metavar="URL")
+parser.add_option("-f", "--fields",
+ action="store_true", dest="fields", default=False,
+ help="Print possible bug fields and exit.")
+
+(options, args) = parser.parse_args()
+
+if not options.user or len(options.user) == 0:
+ parser.error("User name is required.\nTry {0} --help".format(sys.argv[0]))
+
+if not options.password or len(options.password) == 0:
+ parser.error("Password is required.\nTry {0} --help".format(sys.argv[0]))
+
+if not options.bugzilla or len(options.bugzilla) == 0:
+ options.bugzilla = "https://bugzilla.redhat.com/xmlrpc.cgi"
+
+bz = RHBugzilla()
+bz.connect(options.bugzilla)
+bz.login(options.user, options.password)
+
+if options.fields:
+ print bz.bugfields
+ exit(0)
+
+buginfos = bz.query({'status_whiteboard_type':'allwordssubstr','status_whiteboard':'abrt_hash'})
+
+print "{0} bugs found.".format(len(buginfos))
+
+for buginfo in buginfos:
+ # Skip bugs with already downloaded backtraces.
+ filename = "{0}.bt".format(buginfo.bug_id)
+ if os.path.isfile(filename):
+ print "Skipping {0} (already exists).".format(filename)
+ continue
+
+ # Skip bugs with broken or Python backtraces
+ broken_backtrace_bugs = [ 517116, # binary file :)
+ 518516, # not a backtrace, GDB fail
+ 524259, # multiple backtraces in single file
+ 524427, # multiple backtraces in single file
+ 528529, # just [New Thread xx] lines
+ #528915, 10000 frames, out of memory, to be fixed
+ #529422, 10000 frames, out of memory, to be fixed
+ #530239, 10000 frames, out of memory, to be fixed
+ 532264, # no header
+ 533475, # no backtrace
+ #537819, 50000 frames, out of memory, to be fixed
+ #539699, to be fixed, parser bug
+ 539992] # completely broken backtrace
+ if buginfo.bug_id in broken_backtrace_bugs:
+ continue
+
+ # Get backtrace from bug and store it as a file.
+ bug = bz.getbug(buginfo.bug_id)
+ for attachment in bug.attachments:
+ if attachment['filename'] == 'backtrace':
+ data = bz.openattachment(attachment['id'])
+ f = open(filename, 'w')
+ f.write(data.read())
+ f.close()
+ print "Attachment {0} downloaded.".format(filename)
+
+bz.logout()