← Back to team overview

launchpad-reviewers team mailing list archive

lp:~matsubara/python-oops-datedir-repo/833912-duration-as-string into lp:python-oops-datedir-repo

 

Diogo Matsubara has proposed merging lp:~matsubara/python-oops-datedir-repo/833912-duration-as-string into lp:python-oops-datedir-repo.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #833912 in Python OOPS Date-dir repository: "serialize can't read ubuntuone oops report"
  https://bugs.launchpad.net/python-oops-datedir-repo/+bug/833912

For more details, see:
https://code.launchpad.net/~matsubara/python-oops-datedir-repo/833912-duration-as-string/+merge/72936

This branch fixes the case where an oops file has a duration header but the value is a non numerical string.

-- 
https://code.launchpad.net/~matsubara/python-oops-datedir-repo/833912-duration-as-string/+merge/72936
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~matsubara/python-oops-datedir-repo/833912-duration-as-string into lp:python-oops-datedir-repo.
=== modified file 'oops_datedir_repo/serializer_rfc822.py'
--- oops_datedir_repo/serializer_rfc822.py	2011-08-17 00:46:13 +0000
+++ oops_datedir_repo/serializer_rfc822.py	2011-08-25 18:28:52 +0000
@@ -78,7 +78,10 @@
         topic = msg.getheader('page-id')
     username = msg.getheader('user')
     url = msg.getheader('url')
-    duration = int(float(msg.getheader('duration', '-1')))
+    try:
+        duration = int(float(msg.getheader('duration', '-1')))
+    except ValueError:
+        duration = -1
     informational = msg.getheader('informational')
     branch_nick = msg.getheader('branch')
     revno = msg.getheader('revision')

=== modified file 'oops_datedir_repo/tests/test_serializer_rfc822.py'
--- oops_datedir_repo/tests/test_serializer_rfc822.py	2011-08-17 00:38:02 +0000
+++ oops_datedir_repo/tests/test_serializer_rfc822.py	2011-08-25 18:28:52 +0000
@@ -145,6 +145,16 @@
         self.assertEqual(report['branch_nick'], 'mybranch')
         self.assertEqual(report['revno'], '45')
 
+    def test_read_duration_as_string(self):
+        """Test ErrorReport.read()."""
+        fp = StringIO.StringIO(dedent("""\
+            Oops-Id: OOPS-A0001
+            Duration: foo/bar
+
+            """))
+        report = read(fp)
+        self.assertEqual(report['duration'], -1)
+
     def test_read_reporter(self):
         """Test ErrorReport.read()."""
         fp = StringIO.StringIO(dedent("""\