278
280
prefix = oops.get('reporter')
280
282
# Legacy support for pre-reporter using OOPSes.
281
prefix = oops_re.match(oopsid).group('oopsprefix')
283
prefix_match = oops_re.match(oopsid)
284
if prefix_match is not None:
285
prefix = prefix_match.group('oopsprefix')
282
288
prefix = prefix.upper()
284
290
prefix = Prefix.objects.get(value__exact=prefix)
329
335
if total_time < 0:
331
337
# Get the oops infestation
332
exception_type = oops.get('type')
338
exception_type = oops.get('type') or ''
339
exception_value = oops.get('value') or ''
333
340
exception_value = _normalize_exception_value(
334
exception_type, oops.get('value'), prefix)
341
exception_type, exception_value, prefix)
336
343
infestation = Infestation.objects.get(
337
344
exception_type__exact=exception_type,
361
368
most_expensive_statement = conform(most_expensive_statement, 200)
362
369
url = conform(oops.get('url') or '', MAX_URL_LEN)
363
370
informational = oops.get('informational', 'False').lower() == 'true'
371
oops_date = oops.get('time')
372
if oops_date is None:
373
oops_date = datetime.datetime.now(utc)
367
date = oops.get('time').replace(microsecond=0),
377
date = oops_date.replace(microsecond=0),
368
378
# Missing pageids are urls because that suits our queries.
369
379
pageid = oops.get('topic') or url,
377
387
is_bot = _robot_pat.search(data['user_agent']) is not None,
378
388
statements_count = len(statements),
380
return data, req_vars, statements, oops.get('tb_text')
390
return data, req_vars, statements, oops.get('tb_text') or ''
393
def parsed_oops_to_model_oops(parsed_oops, pathname):
394
"""Convert an oops report dict to an Oops object."""
395
data, req_vars, statements, traceback = _get_oops_tuple(parsed_oops)
396
data['pathname'] = pathname
398
res.appinstance = res.get_appinstance()
400
# Get it again. Otherwise we have discrepancies between old and
401
# new oops objects: old ones have unicode attributes, and new
402
# ones have string attributes, for instance. Ideally the message
403
# conversion would have converted everything to unicode, but it
405
res = Oops.objects.get(oopsid__exact=parsed_oops['id'])
406
res.parsed_oops = parsed_oops
407
res.req_vars = req_vars
408
res.statements = statements
409
res.traceback = traceback
383
414
class Oops(models.Model):
433
464
res = cls.objects.get(oopsid__exact=oopsid)
434
465
except cls.DoesNotExist:
435
data, req_vars, statements, traceback = _get_oops_tuple(parsed_oops)
436
data['pathname'] = pathname
438
res.appinstance = res.get_appinstance()
440
# Get it again. Otherwise we have discrepancies between old and
441
# new oops objects: old ones have unicode attributes, and new
442
# ones have string attributes, for instance. Ideally the message
443
# conversion would have converted everything to unicode, but it
445
res = cls.objects.get(oopsid__exact=oopsid)
446
res.parsed_oops = parsed_oops
447
res.req_vars = req_vars
448
res.statements = statements
449
res.traceback = traceback
466
res = parsed_oops_to_model_oops(parsed_oops, pathname)