From dbce0ff6f2e4fd964443198f603c16a0acd2b653 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 8 Aug 2005 10:53:31 +0000 Subject: [PATCH] Copy downlaoded GPG key to a temporary file, as Python 2.4 doesn't seem to support fileno() anymore (reported by Kurt B Cox). git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/injector/injector@403 9f8c893c-44ee-0310-b757-c8ca8341c71e --- zeroinstall/injector/iface_cache.py | 14 +++++++++++--- zeroinstall/zerostore/__init__.py | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/zeroinstall/injector/iface_cache.py b/zeroinstall/injector/iface_cache.py index c29c0e4..8f172eb 100644 --- a/zeroinstall/injector/iface_cache.py +++ b/zeroinstall/injector/iface_cache.py @@ -1,7 +1,7 @@ """The interface cache stores downloaded and verified interfaces in ~/.cache/0install.net/interfaces (by default). There are methods to query the cache, add to it, check signatures, etc.""" -import os, sys, time +import os, sys, time, tempfile, shutil from logging import debug, info, warn from cStringIO import StringIO @@ -88,11 +88,19 @@ class IfaceCache(object): info("Fetching key from %s", key_url) try: stream = urllib2.urlopen(key_url) + # Python2.4: can't call fileno() on stream, so save to tmp file instead + tmpfile = tempfile.TemporaryFile(prefix = 'injector-dl-data-') + shutil.copyfileobj(stream, tmpfile) + tmpfile.flush() + stream.close() except Exception, ex: raise SafeException("Failed to download key from '%s': %s" % (key_url, str(ex))) + import gpg - gpg.import_key(stream) - stream.close() + + tmpfile.seek(0) + gpg.import_key(tmpfile) + tmpfile.close() def update_interface_from_network(self, interface, new_xml, modified_time): """xml is the new XML (after the signature has been checked and diff --git a/zeroinstall/zerostore/__init__.py b/zeroinstall/zerostore/__init__.py index 0fffada..6e91318 100644 --- a/zeroinstall/zerostore/__init__.py +++ b/zeroinstall/zerostore/__init__.py @@ -21,6 +21,7 @@ if '(GNU tar)' in _version: recent_gnu_tar = _version > [1, 14, 0] except: warn("Failed to extract GNU tar version number") +del _version def copytree2(src, dst): names = os.listdir(src) -- 2.11.4.GIT