From 6387f87f625c83ba8fcfe5aa3ccf6ac6fc246a96 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 18 May 2008 09:54:05 +0100 Subject: [PATCH] Updated get_details to use subprocess module. Unit-tests were failing on Python 2.6a3. allpython.sh now tests 2.4, 2.5 and 2.6. --- tests/allpython.sh | 2 +- zeroinstall/injector/gpg.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/allpython.sh b/tests/allpython.sh index 84f2450..bfbb995 100755 --- a/tests/allpython.sh +++ b/tests/allpython.sh @@ -1,5 +1,5 @@ #!/bin/sh set -e -x -for version in 2.4 2.5; do +for version in 2.4 2.5 2.6; do python$version ./testall.py done diff --git a/zeroinstall/injector/gpg.py b/zeroinstall/injector/gpg.py index 22f7048..3b3c56d 100644 --- a/zeroinstall/injector/gpg.py +++ b/zeroinstall/injector/gpg.py @@ -9,10 +9,12 @@ This module is used to invoke GnuPG to check the digital signatures on interface # Copyright (C) 2006, Thomas Leonard # See the README file for details, or visit http://0install.net. +import subprocess import base64, re import os import tempfile import traceback +from logging import info from zeroinstall import support from zeroinstall.injector.trust import trust_db @@ -54,12 +56,13 @@ class ValidSig(Signature): def get_details(self): """Call 'gpg --list-keys' and return the results split into lines and columns. @rtype: [[str]]""" - cin, cout = os.popen2(('gpg', '--with-colons', '--no-secmem-warning', '--list-keys', self.fingerprint)) - cin.close() + child = subprocess.Popen(['gpg', '--with-colons', '--no-secmem-warning', '--list-keys', self.fingerprint], stdout = subprocess.PIPE) + cout, unused = child.communicate() + if child.returncode: + info("GPG exited with code %d" % child.returncode) details = [] - for line in cout: + for line in cout.split('\n'): details.append(line.split(':')) - cout.close() return details class BadSig(Signature): -- 2.11.4.GIT