← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rye/python-oops-tools/u1-prefix-support into lp:python-oops-tools

 

Roman Yepishev has proposed merging lp:~rye/python-oops-tools/u1-prefix-support into lp:python-oops-tools.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #891647 in python-oops-tools: "Need special handling for current U1 OOPS-IDs"
  https://bugs.launchpad.net/python-oops-tools/+bug/891647

For more details, see:
https://code.launchpad.net/~rye/python-oops-tools/u1-prefix-support/+merge/82556

This adds U1 OOPS prefix format parsing. Test for the OOPS-<hash> passed too.
-- 
https://code.launchpad.net/~rye/python-oops-tools/u1-prefix-support/+merge/82556
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rye/python-oops-tools/u1-prefix-support into lp:python-oops-tools.
=== modified file 'src/oopstools/oops/models.py'
--- src/oopstools/oops/models.py	2011-11-16 22:46:04 +0000
+++ src/oopstools/oops/models.py	2011-11-17 16:19:23 +0000
@@ -281,11 +281,18 @@
     if not prefix:
         # Legacy support for pre-reporter using OOPSes.
         prefix_match = oops_re.match(oopsid)
-        # 37 is len (OOPS-<hash>).
-        if prefix_match is not None and len(oopsid) < 37:
+        if prefix_match:
             prefix = prefix_match.group('oopsprefix')
-        else:
+            # Ubuntu One format is prefixZuuid.
+            if len(prefix) > 33 and prefix[-33] == 'Z':
+                prefix = prefix[:-33]
+            elif len(oopsid) >= 37:
+                # 37 is len (OOPS-<hash>).
+                prefix = None
+
+        if not prefix:
             prefix = 'UNKNOWN'
+
     prefix = prefix.upper()
     try:
         prefix = Prefix.objects.get(value__exact=prefix)

=== modified file 'src/oopstools/oops/test/test_dboopsloader.py'
--- src/oopstools/oops/test/test_dboopsloader.py	2011-11-16 07:43:57 +0000
+++ src/oopstools/oops/test/test_dboopsloader.py	2011-11-17 16:19:23 +0000
@@ -242,3 +242,14 @@
         }
         oops = parsed_oops_to_model_oops(report, 'bug-889982')
         self.assertEqual('UNKNOWN', oops.appinstance.title)
+
+    def test_u1_report_id_bug_891647(self):
+        # Ubuntu One web apps use their own flavour of unique identifier for
+        # the oopses: prefixZuuid_encoded. We need to make sure that prefix
+        # does not end up being such a string.
+        report = {
+            'id': 'OOPS-2147appserver'\
+                  'ZCeCCGJBHEHJCEdABaIIJDCbaJbaAbDce175347', 
+        }
+        oops = parsed_oops_to_model_oops(report, 'bug-891647')
+        self.assertEqual('APPSERVER', oops.appinstance.title)