[Piuparts-commits] [piuparts] 03/04: open_packages_url: try .gz if .bz2 is not available
Holger Levsen
holger at alioth.debian.org
Thu Oct 31 12:04:52 UTC 2013
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch develop
in repository piuparts.
commit 4a35f9fa1d1b7475ba5c85619805ba03f1cf03a9
Author: Andreas Beckmann <anbe at debian.org>
Date: Wed Oct 30 19:51:51 2013 +0100
open_packages_url: try .gz if .bz2 is not available
Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
debian/changelog | 3 +++
piupartslib/__init__.py | 13 ++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 2e0635e..89ea179 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,9 @@ piuparts (0.56) UNRELEASED; urgency=low
* piuparts.py:
- Add to ignored_files:
+ /etc/apt/apt.conf.d/01autoremove-kernels
+ * piupartslib/__init__.py:
+ - open_packages_url(): Try Packages.gz if Packages.bz2 is not available.
+ (Closes: #711157)
-- Andreas Beckmann <anbe at debian.org> Tue, 22 Oct 2013 22:16:21 +0200
diff --git a/piupartslib/__init__.py b/piupartslib/__init__.py
index 8130c06..4eb6cd6 100644
--- a/piupartslib/__init__.py
+++ b/piupartslib/__init__.py
@@ -18,6 +18,7 @@
import bz2
+import gzip
import urllib2
import cStringIO
@@ -32,7 +33,7 @@ def open_packages_url(url):
assert url.endswith(".bz2")
url = url[:-len(".bz2")]
socket = None
- for ext in ['.bz2']:
+ for ext in ['.bz2', '.gz']:
try:
socket = urllib2.urlopen(url + ext)
except urllib2.HTTPError as httperror:
@@ -51,6 +52,16 @@ def open_packages_url(url):
break
decompressed.write(decompressor.decompress(data))
decompressed.seek(0)
+ elif ext == '.gz':
+ compressed = cStringIO.StringIO()
+ while True:
+ data = socket.read(1024)
+ if not data:
+ socket.close()
+ break
+ compressed.write(data)
+ compressed.seek(0)
+ decompressed = gzip.GzipFile(fileobj=compressed)
else:
raise ext
return decompressed
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git
More information about the Piuparts-commits
mailing list