launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05984
[Merge] lp:~mbp/python-oops-datedir-repo/bsondump into lp:python-oops-datedir-repo
Martin Pool has proposed merging lp:~mbp/python-oops-datedir-repo/bsondump into lp:python-oops-datedir-repo.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~mbp/python-oops-datedir-repo/bsondump/+merge/86338
This copies in the little bsondump script to make oops files readable.
It's a bit unclear which of the many oops components this really belongs in - it's not specific to storing it in per-date directories - but wgrant wanted it here, so here it is.
--
https://code.launchpad.net/~mbp/python-oops-datedir-repo/bsondump/+merge/86338
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/python-oops-datedir-repo/bsondump into lp:python-oops-datedir-repo.
=== modified file '.bzrignore'
--- .bzrignore 2011-11-11 04:48:53 +0000
+++ .bzrignore 2011-12-20 05:30:30 +0000
@@ -9,3 +9,4 @@
./dist
./MANIFEST
.testrepository
+./build
=== added directory 'scripts'
=== added file 'scripts/bsondump'
--- scripts/bsondump 1970-01-01 00:00:00 +0000
+++ scripts/bsondump 2011-12-20 05:30:30 +0000
@@ -0,0 +1,30 @@
+#! /usr/bin/python
+
+"""Print a BSON document for easier human inspection.
+
+This can be used for oopses, which are commonly (though not necessarily)
+stored as BSON.
+
+usage: bsondump FILE
+"""
+
+import bson
+from pprint import pprint
+import sys
+
+if len(sys.argv) != 2:
+ print __doc__
+ sys.exit(1)
+
+
+def decode_somehow(filename):
+ """There are several bson apis: try to decode it while crying."""
+ fn = getattr(bson, 'loads', None) or getattr(bson, 'decode_all')
+ return fn(file(filename, 'rb').read())
+
+
+# I'd like to use json here, but not everything serializable in bson is
+# easily representable in json - even before getting in to the weird parts,
+# oopses commonly have datetime objects. -- mbp 2011-12-20
+
+pprint(decode_somehow(sys.argv[1]))
=== modified file 'setup.py'
--- setup.py 2011-12-08 03:05:06 +0000
+++ setup.py 2011-12-20 05:30:30 +0000
@@ -30,6 +30,9 @@
url="https://launchpad.net/python-oops-datedir-repo",
packages=['oops_datedir_repo'],
package_dir = {'':'.'},
+ scripts = [
+ 'scripts/bsondump',
+ ],
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',