Fix usage of the subprocess module under Python 2.6

This commit is contained in:
Laurent Bachelier 2012-01-30 15:40:12 +01:00
commit 09e3c516d0

View file

@ -159,23 +159,25 @@ class WeboobRepos(ReplApplication):
# Find out which keys are allowed to sign # Find out which keys are allowed to sign
fingerprints = [line.strip(':').split(':')[-1] fingerprints = [line.strip(':').split(':')[-1]
for line for line
in subprocess.check_output([gpg, in subprocess.Popen([gpg,
'--with-fingerprint', '--with-colons', '--with-fingerprint', '--with-colons',
'--list-public-keys', '--list-public-keys',
'--no-default-keyring', '--no-default-keyring',
'--keyring', os.path.realpath(krname)]).splitlines() '--keyring', os.path.realpath(krname)],
stdout=subprocess.PIPE).communicate()[0].splitlines()
if line.startswith('fpr:')] if line.startswith('fpr:')]
# Find out the first secret key we have that is allowed to sign # Find out the first secret key we have that is allowed to sign
secret_fingerprint = None secret_fingerprint = None
for fingerprint in fingerprints: for fingerprint in fingerprints:
try: proc = subprocess.Popen([gpg,
subprocess.check_output([gpg, '--list-secret-keys', fingerprint],
'--list-secret-keys', fingerprint], stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
secret_fingerprint = fingerprint proc.communicate()
break # if failed
except subprocess.CalledProcessError: if proc.returncode:
pass continue
secret_fingerprint = fingerprint
if secret_fingerprint is None: if secret_fingerprint is None:
raise Exception('No suitable secret key found') raise Exception('No suitable secret key found')