Merge lp:~matsubara/python-oops-datedir-repo/improve-db-statement-matches into lp:python-oops-datedir-repo
Proposed by
Diogo Matsubara
Status: | Merged |
---|---|
Approved by: | Diogo Matsubara |
Approved revision: | 10 |
Merged at revision: | 10 |
Proposed branch: | lp:~matsubara/python-oops-datedir-repo/improve-db-statement-matches |
Merge into: | lp:python-oops-datedir-repo |
Diff against target: |
100 lines (+18/-19) 2 files modified
oops_datedir_repo/serializer_rfc822.py (+14/-17) oops_datedir_repo/tests/test_serializer_rfc822.py (+4/-2) |
To merge this branch: | bzr merge lp:~matsubara/python-oops-datedir-repo/improve-db-statement-matches |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Abel Deuring (community) | code | Approve | |
Review via email: mp+73059@code.launchpad.net |
Description of the change
This branch fixes a couple of small things:
- improves how request variables and db statements are identified by the parser. Before, it'd allow db statements to be read as if they were request variables. The check for request variables is now a bit more precise.
- Duration got from oops report file is now parsed as a float rather than as an int.
- The first traceback line is preserved avoiding a traceback without a newline character in its first line.
To post a comment you must log in.
Hi Diogo,
the branch looks good.
Just a minor suggestion:
> === modified file 'oops_datedir_ repo/serializer _rfc822. py' repo/serializer _rfc822. py 2011-08-25 20:53:24 +0000 repo/serializer _rfc822. py 2011-08-26 14:17:14 +0000 'exception- value') 'date') parse_date( msg.getheader( 'date') ) parse_date( msg.getheader( 'date') ) 'topic' ) 'user') 'url') msg.getheader( 'duration' , '-1'))) getheader( 'duration' , '-1')) 'informational' ) 'branch' ) 'revision' ) r'^(\d+ )-(\d+) (?:@([\ w-]+))? \s+(.*) ') r'^(\d+ )-(\d+) (?:@([\ w-]+))? \s+(.*) ', line) pat.match( line)
> --- oops_datedir_
> +++ oops_datedir_
> @@ -70,7 +70,7 @@
> exc_value = msg.getheader(
> datestr = msg.getheader(
> if datestr is not None:
> - date =iso8601.
> + date = iso8601.
> else:
> date = None
> topic = msg.getheader(
> @@ -79,9 +79,9 @@
> username = msg.getheader(
> url = msg.getheader(
> try:
> - duration = int(float(
> + duration = float(msg.
> except ValueError:
> - duration = -1
> + duration = float(-1)
> informational = msg.getheader(
> branch_nick = msg.getheader(
> revno = msg.getheader(
> @@ -94,28 +94,27 @@
> lines = iter(msg.fp)
>
> def is_req_var(line):
> - return "=" in line
> + return "=" in line and not is_statement(line)
>
> + statement_pat = re.compile(
> def is_statement(line):
> - return re.match(
> + return statement_
is_statement() returns a match object or None, from statement_ pat.match( )...
> ).startswith( 'traceback' ) or line.startswith( append( (urllib. unquote( key), urllib. unquote( value)) ) )-(\d+) (?:@([\ w-]+))? \s+(.*) ', line) pat.match( line)
> def is_traceback(line):
> - return 'traceback' in line.lower() or '== EXTRA DATA ==' in line
> + return line.lower(
> + '== EXTRA DATA ==')
>
> req_vars = []
> statements = []
> first_tb_line = ''
> for line in lines:
> + first_tb_line = line
> line = line.strip()
> if line == '':
> continue
> else:
> - if is_req_var(line):
> - key, value = line.split('=', 1)
> - req_vars.
> - elif is_statement(line):
> - match = re.match(
> - r'^(\d+
> + if is_statement(line):
> + match = statement_
> assert match is not None, (
> "Unable to interpret oops line: %s" % line)
... and here, statement_ pat.match( ) is called again. I think
you don't need is_statement() at all: Something like
match = statement_ pat.match( line)
if match is not None:
start, end, db_id, statement = match.groups()
would be "good enough" :)