From fa83ac6b0bd5801ee0dadc401af08a46893c07a5 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 20 Jun 2012 22:28:35 +0200 Subject: [PATCH] seeded-in-ubuntu: Catch errors in parsing data, and don't keep unreadable data cached (LP: #1008783) --- debian/changelog | 2 ++ seeded-in-ubuntu | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index e022b0c..73e9411 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ ubuntu-dev-tools (0.143) UNRELEASED; urgency=low * Correct metavar for --mirror in backportpackage (LP: #999727) * submittodebian: Explitictly UTF-8 encode the bug body (LP: #1005834) * backportpackage.1: Document --key and --dont-sign (LP: #1007564) + * seeded-in-ubuntu: Catch errors in parsing data, and don't keep unreadable + data cached (LP: #1008783) -- Mathieu Trudel-Lapierre Wed, 06 Jun 2012 09:53:24 -0400 diff --git a/seeded-in-ubuntu b/seeded-in-ubuntu index 16d347d..dcf7676 100755 --- a/seeded-in-ubuntu +++ b/seeded-in-ubuntu @@ -43,8 +43,14 @@ def load_index(url): os.makedirs(cachedir) urllib.urlretrieve(url, fn) - with gzip.open(fn, 'r') as f: - return json.load(f) + try: + with gzip.open(fn, 'r') as f: + return json.load(f) + except Exception, e: + Logger.error("Unable to parse seed data: %s. " + "Deleting cached data, please try again.", + str(e)) + os.unlink(fn) def resolve_binaries(sources):