diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-11-27 15:36:39 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-11-27 15:36:39 +0100 |
commit | 7c369d2be972c4aee919252cd850cae3b772e9bc (patch) | |
tree | 6fc0ef0f9f8be5e36e81e8e09cbc8b6385becaa3 | |
parent | 073bb2c022a2eb9031f6ef84970c3fa153e764a7 (diff) | |
download | gemato-7c369d2be972c4aee919252cd850cae3b772e9bc.tar.gz |
openpgp: Support executable named 'gpg2' (Debian)
-rw-r--r-- | gemato/openpgp.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gemato/openpgp.py b/gemato/openpgp.py index 56257f5..c3c2f4e 100644 --- a/gemato/openpgp.py +++ b/gemato/openpgp.py @@ -13,20 +13,24 @@ import gemato.exceptions def _spawn_gpg(options, env_instance, stdin): env = None + impls = ['gpg2', 'gpg'] if env_instance is not None: env={'GNUPGHOME': env_instance.home} - try: - p = subprocess.Popen(['gpg', '--batch'] + options, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=env) - except OSError as e: - if e.errno == errno.ENOENT: - raise gemato.exceptions.OpenPGPNoImplementation() + for impl in impls: + try: + p = subprocess.Popen([impl, '--batch'] + options, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env) + except OSError as e: + if e.errno != errno.ENOENT: + raise else: - raise + break + else: + raise gemato.exceptions.OpenPGPNoImplementation() if env_instance is not None: env_instance._set_started() |