diff options
author | David Malcolm <dmalcolm@redhat.com> | 2012-12-10 14:24:24 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2012-12-10 14:24:24 -0500 |
commit | 015add8c24e8ed0ac99239c8368d8944d337e929 (patch) | |
tree | 579414bc8a244f369dae4eefbd72ccec490f89f5 /bug.py | |
parent | 33943593f1fc08c469285d9575704e403490997e (diff) | |
download | triage-015add8c24e8ed0ac99239c8368d8944d337e929.tar.gz triage-015add8c24e8ed0ac99239c8368d8944d337e929.tar.xz triage-015add8c24e8ed0ac99239c8368d8944d337e929.zip |
split out the source into new files
Diffstat (limited to 'bug.py')
-rw-r--r-- | bug.py | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -0,0 +1,60 @@ +from pprint import pprint +import re + +from backtrace import Backtrace + +class Bug(object): + def __init__(self, bz, id): + self.bz = bz + self.id = id + self._bug = bz.getbug(id) + if 1: + pprint(self._bug.__dict__) + + def get_backtrace(self): + # Get the backtrace associated with this ABRT bug, as a Backtrace instance + a = self._get_backtrace_info() + if a is None: + raise NoBacktrace() + return Backtrace(self.bz.openattachment(a['attach_id']).read()) + + def _get_backtrace_info(self): + for a in self._bug.attachments: + if a['filename'] == 'backtrace': + return a + + def get_script(self): + '''Parse the ABRT report, extracting the script''' + # print repr(self._bug.longdescs[0]['body']) + for line in self._bug.longdescs[0]['body'].splitlines(): + m = re.match('cmdline: (.+)', line) + if m: + for arg in m.group(1).split()[1:]: + if arg.startswith('/'): + return arg + if arg.endswith('.py'): + return arg + + def get_abrt_reason(self): + for line in self._bug.longdescs[0]['body'].splitlines(): + m = re.match('reason: (.+)', line) + if m: + return m.group(1) + + def get_abrt_signal(self): + reason = self.get_abrt_reason() + if reason is None: + return + + m = re.match('Process was terminated by signal ([0-9]+)', reason) + if m: + sig = int(m.group(1)) + import signal + for signame in dir(signal): + if signame.startswith('SIG'): + if getattr(signal, signame) == sig: + return signame + +class NoBacktrace(Exception): + pass + |