From 09e3c516d06349ed3f07a65394dc65a7b0d28650 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Mon, 30 Jan 2012 15:40:12 +0100 Subject: [PATCH] Fix usage of the subprocess module under Python 2.6 --- .../applications/weboobrepos/weboobrepos.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/weboob/applications/weboobrepos/weboobrepos.py b/weboob/applications/weboobrepos/weboobrepos.py index 7f6e10af..a8c05e8e 100644 --- a/weboob/applications/weboobrepos/weboobrepos.py +++ b/weboob/applications/weboobrepos/weboobrepos.py @@ -159,23 +159,25 @@ class WeboobRepos(ReplApplication): # Find out which keys are allowed to sign fingerprints = [line.strip(':').split(':')[-1] for line - in subprocess.check_output([gpg, + in subprocess.Popen([gpg, '--with-fingerprint', '--with-colons', '--list-public-keys', '--no-default-keyring', - '--keyring', os.path.realpath(krname)]).splitlines() + '--keyring', os.path.realpath(krname)], + stdout=subprocess.PIPE).communicate()[0].splitlines() if line.startswith('fpr:')] # Find out the first secret key we have that is allowed to sign secret_fingerprint = None for fingerprint in fingerprints: - try: - subprocess.check_output([gpg, - '--list-secret-keys', fingerprint], - stderr=subprocess.PIPE) - secret_fingerprint = fingerprint - break - except subprocess.CalledProcessError: - pass + proc = subprocess.Popen([gpg, + '--list-secret-keys', fingerprint], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + proc.communicate() + # if failed + if proc.returncode: + continue + secret_fingerprint = fingerprint if secret_fingerprint is None: raise Exception('No suitable secret key found')