Merge lp:~sidnei/python-oops-datedir-repo/bz2-oops-serializer into lp:python-oops-datedir-repo

Proposed by Sidnei da Silva
Status: Merged
Merged at revision: 35
Proposed branch: lp:~sidnei/python-oops-datedir-repo/bz2-oops-serializer
Merge into: lp:python-oops-datedir-repo
Diff against target: 80 lines (+18/-3)
4 files modified
NEWS (+4/-0)
oops_datedir_repo/serializer.py (+4/-0)
oops_datedir_repo/tests/test_serializer.py (+7/-0)
versions.cfg (+3/-3)
To merge this branch: bzr merge lp:~sidnei/python-oops-datedir-repo/bz2-oops-serializer
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+95453@code.launchpad.net

Commit message

If it smells like bz2, it probably is, so decompress it.

Description of the change

If it smells like bz2, it probably is, so decompress it.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Thanks for this; please add a NEWS entry?

review: Approve
37. By Sidnei da Silva

- Add NEWS entry

Revision history for this message
Robert Collins (lifeless) wrote :

I'll do a release as I land this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2012-02-28 18:36:53 +0000
3+++ NEWS 2012-03-01 20:59:23 +0000
4@@ -6,6 +6,10 @@
5 NEXT
6 ----
7
8+* If the oops being unserialized smells like a .bz2 file (by looking at the
9+ magic 'BZh' marker) then it probably is, so bz2.decompress() it.
10+ (Sidnei da Silva)
11+
12 0.0.16
13 ------
14
15
16=== modified file 'oops_datedir_repo/serializer.py'
17--- oops_datedir_repo/serializer.py 2012-02-10 19:24:56 +0000
18+++ oops_datedir_repo/serializer.py 2012-03-01 20:59:23 +0000
19@@ -33,6 +33,8 @@
20 'read',
21 ]
22
23+import bz2
24+
25 from StringIO import StringIO
26
27 from oops_datedir_repo import (
28@@ -54,6 +56,8 @@
29 if len(content) == 0:
30 # This OOPS has no content
31 raise IOError("Empty OOPS Report")
32+ if content[0:3] == "BZh":
33+ content = bz2.decompress(content)
34 try:
35 return serializer_bson.read(StringIO(content))
36 except (KeyError, bson.InvalidBSON):
37
38=== modified file 'oops_datedir_repo/tests/test_serializer.py'
39--- oops_datedir_repo/tests/test_serializer.py 2012-02-10 19:24:56 +0000
40+++ oops_datedir_repo/tests/test_serializer.py 2012-03-01 20:59:23 +0000
41@@ -17,6 +17,7 @@
42
43 __metaclass__ = type
44
45+import bz2
46 import datetime
47 import StringIO
48
49@@ -67,6 +68,12 @@
50 source_file.seek(0)
51 self.assertEqual(self.expected_dict, read(source_file))
52
53+ def test_read_detect_bz2(self):
54+ source_file = StringIO.StringIO()
55+ source_file.write(bz2.compress(dumps(dict(self.source_dict))))
56+ source_file.seek(0)
57+ self.assertEqual(self.expected_dict, read(source_file))
58+
59 def test_ioerror_on_empty_oops(self):
60 source_file = StringIO.StringIO()
61 self.assertRaises(IOError, read, source_file)
62
63=== modified file 'versions.cfg'
64--- versions.cfg 2011-11-15 21:47:32 +0000
65+++ versions.cfg 2012-03-01 20:59:23 +0000
66@@ -13,11 +13,11 @@
67 lazr.restfulclient = 0.12.0
68 lazr.uri = 1.0.2
69 oauth = 1.0.0
70-oops = 0.0.8
71-pytz = 2010o
72+oops = 0.0.10
73+pytz = 2011n
74 setuptools = 0.6c11
75 simplejson = 2.1.3
76-testtools = 0.9.11
77+testtools = 0.9.14
78 wadllib = 1.2.0
79 wsgi-intercept = 0.4
80 zc.recipe.egg = 1.3.2

Subscribers

People subscribed via source and target branches

to all changes: