| 202 | |
| 203 | |
| 204 | def crashReport(results_path: str, query_params: dict): |
| 205 | pkgs = '' if query_params.get('pkgs') == '1' else None |
| 206 | |
| 207 | html = '<!DOCTYPE html>\n' |
| 208 | html += '<html><head><title>Crash report</title></head><body>\n' |
| 209 | html += '<h1>Crash report</h1>\n' |
| 210 | html += '<pre>\n' |
| 211 | html += '<b>' + fmt('Package', 'Date Time', OLD_VERSION, 'Head', link=False) + '</b>\n' |
| 212 | current_year = datetime.date.today().year |
| 213 | stack_traces = {} |
| 214 | for filename in sorted(glob.glob(os.path.expanduser(results_path + '/*'))): |
| 215 | if not os.path.isfile(filename) or filename.endswith('.diff'): |
| 216 | continue |
| 217 | with open(filename, 'rt') as file_: |
| 218 | datestr = None |
| 219 | package_url = None |
| 220 | for line in file_: |
| 221 | line = line.strip() |
| 222 | if line.startswith('cppcheck: '): |
| 223 | if OLD_VERSION not in line: |
| 224 | # Package results seem to be too old, skip |
| 225 | break |
| 226 | # Current package, parse on |
| 227 | continue |
| 228 | if datestr is None and line.startswith(str(current_year) + '-') or line.startswith(str(current_year - 1) + '-'): |
| 229 | datestr = line |
| 230 | elif pkgs is not None and package_url is None and line.startswith('ftp://'): |
| 231 | package_url = line |
| 232 | elif line.startswith('count:'): |
| 233 | if line.find('Crash') < 0: |
| 234 | break |
| 235 | package = pkg_from_file(filename) |
| 236 | counts = line.split(' ') |
| 237 | c_version = '' |
| 238 | if counts[2] == 'Crash!': |
| 239 | c_version = 'Crash' |
| 240 | c_head = '' |
| 241 | if counts[1] == 'Crash!': |
| 242 | c_head = 'Crash' |
| 243 | html += fmt(package, datestr, c_version, c_head) + '\n' |
| 244 | if c_head != 'Crash': |
| 245 | break |
| 246 | if package_url is not None: |
| 247 | pkgs += '{}\n'.format(package_url) |
| 248 | elif line.find(' received signal ') != -1: |
| 249 | crash_line = next(file_, '').strip() |
| 250 | location_index = crash_line.rfind(' at ') |
| 251 | if location_index > 0: |
| 252 | code_line = next(file_, '').strip() |
| 253 | else: |
| 254 | code_line = '' |
| 255 | stack_trace = [] |
| 256 | while True: |
| 257 | l = next(file_, '') |
| 258 | if not l.strip(): |
| 259 | break |
| 260 | # #0 0x00007ffff71cbf67 in raise () from /lib64/libc.so.6 |
| 261 | m = re.search(r'(?P<number>#\d+) .* in (?P<function>.+)\(.*\) from (?P<binary>.*)$', l) |