Merge lp:~pkern/ubuntu-cve-tracker/master into lp:~ubuntu-security/ubuntu-cve-tracker/master

Proposed by Philipp Kern
Status: Rejected
Rejected by: Jamie Strandboge
Proposed branch: lp:~pkern/ubuntu-cve-tracker/master
Merge into: lp:~ubuntu-security/ubuntu-cve-tracker/master
Diff against target: 41 lines (+13/-2)
1 file modified
scripts/convert-pickle.py (+13/-2)
To merge this branch: bzr merge lp:~pkern/ubuntu-cve-tracker/master
Reviewer Review Type Date Requested Status
Marc Deslauriers Pending
Review via email: mp+233670@code.launchpad.net

Description of the change

The JSON USN database is huge and can benefit a lot from compression. It does not look like it already serves a compressed copy. Furthermore the cron parts are missing in the source, hence I simply patched the pickle to JSON converter.

To post a comment you must log in.
Revision history for this message
Philipp Kern (pkern) wrote :

FWIW, for instance Cloud services like AppEngine can only download 32 MiB per chunk over HTTP, hence this proposal.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

We already offer compressed (bz2) alongside the uncompressed files.

From IRC:
07:37 < jdstrand> mdeslaur, and pkern: so, there are already bz2 files created:
                  cd $UCT/scripts/fetch-db database.pickle.bz2
07:37 < jdstrand> ...
07:38 < jdstrand> = Fetching database.pickle.bz2 =
07:38 < jdstrand> --2014-09-10 07:37:36--
                  https://usn.ubuntu.com/usn-db/database.pickle.bz2
07:38 < jdstrand> ...
07:38 < jdstrand> = Fetching database.pickle.bz2.sha256 =
07:38 < jdstrand> --2014-09-10 07:37:49--
                  https://usn.ubuntu.com/usn-db/database.pickle.bz2.sha256
07:38 < jdstrand> ...
07:38 < jdstrand> = Verifiying database.pickle.bz2.sha256 =
07:38 < jdstrand> ./database.pickle.bz2: OK
07:38 < jdstrand> = Uncompressing database.pickle.bz2 =
07:38 < jdstrand> Download complete. File saved to 'database.pickle'
07:38 < jdstrand> so that is the pickle file
07:38 < jdstrand> but the json is there too
07:38 < jdstrand> $ $UCT/scripts/fetch-db database.json.bz2
07:38 < jdstrand> = Fetching database.json.bz2 =
07:38 < jdstrand> --2014-09-10 07:38:47--
                  https://usn.ubuntu.com/usn-db/database.json.bz2
07:38 < jdstrand> ...
07:39 < jdstrand> = Fetching database.json.bz2.sha256 =
07:39 < jdstrand> --2014-09-10 07:38:55--
                  https://usn.ubuntu.com/usn-db/database.json.bz2.sha256
07:39 < jdstrand> ...
07:39 < jdstrand> = Verifiying database.json.bz2.sha256 =
07:39 < jdstrand> ./database.json.bz2: OK
07:39 < jdstrand> = Uncompressing database.json.bz2 =
07:39 < jdstrand> Download complete. File saved to 'database.json'

Unmerged revisions

8455. By pkern <pkern@localhost>

Save the JSON database gzip'ed as well, which makes for much smaller files.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/convert-pickle.py'
2--- scripts/convert-pickle.py 2012-04-26 21:27:31 +0000
3+++ scripts/convert-pickle.py 2014-09-08 07:37:44 +0000
4@@ -9,16 +9,28 @@
5
6 import codecs
7 import cPickle
8+import cStringIO
9+import gzip
10 import json
11 import optparse
12 import os
13+import shutil
14 import sys
15
16 # TODO: move these to usn_lib.py
17 def save_database_json(database, db_filename):
18 '''Save usn database'''
19 filename = os.path.expanduser(db_filename)
20- json.dump(database, open(filename, 'w'), -1, encoding="utf-8")
21+ buf = cStringIO.StringIO()
22+ json.dump(database, buf, -1, encoding="utf-8")
23+ buf.seek(0)
24+ print >>sys.stderr, "INFO: Saving %s..." % (filename)
25+ with open(filename, 'w') as outf:
26+ shutil.copyfileobj(buf, outf)
27+ buf.seek(0)
28+ print >>sys.stderr, "INFO: Saving %s..." % (filename + '.gz')
29+ with gzip.GzipFile(filename + '.gz', 'w') as outf:
30+ shutil.copyfileobj(buf, outf)
31
32 def convert_pickle_to_json(indb, outdb):
33 '''Convert a pickle database into a json'''
34@@ -47,7 +59,6 @@
35 if count > 0:
36 print >>sys.stderr, "WARN: performed %d pickle decode conversions" % count
37
38- print >>sys.stderr, "INFO: Saving %s..." % (outdb)
39 save_database_json(new_db, outdb)
40
41 #