#! /usr/bin/python '''Apport utility to download an apport report from a bug. Useful to test apport package hooks, or for local processing. Short and straight to the point. Copyright (C) 2009 C de-Avillez hggdh2@gmail.com Author: C de-Avillez hggdh2@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See http://www.gnu.org/copyleft/gpl.html for the full text of the license. ''' from apport.crashdb import get_crashdb from optparse import OptionParser import sys import os usage = 'usage: %prog --outf= --bug=nnnnnn' parser = OptionParser(usage) parser.add_option('-o', '--outf', action='store', type='string', dest='outCrashFile', help='output crash report file name') parser.add_option('-b', '--bug', action='store', type='string', dest='bugNum', help='LP bug to download apport-generated attachments as an apport crash file') (opt, args) = parser.parse_args() if parser.get_option('outf') == 'None': parser.error ('required option "--outf" not provided.') if parser.get_option('bug') == 'None': parser.error ('required option "--bug" not provided.') c=get_crashdb(None) try: r=c.download(opt.bugNum) except KeyError: parser.error('provided --bug not found in LaunchPad') r.write(open(opt.outCrashFile, 'w'))