Commit 78b2236c authored by ale's avatar ale

allow setting gpg binary from environment

parent 4c67d4fb
......@@ -81,7 +81,8 @@ sig-notation issuer-fpr@notations.openpgp.fifthhorseman.net=%%g
default-key %s\n
''' % self.secret_key_id)
# Create the gnupg.GPG object to talk to gnupg.
gpg = gnupg.GPG(homedir=tmpdir,
gpg = gnupg.GPG(binary=_default_gpgbinary(),
homedir=tmpdir,
keyring=public_keyring,
secring=self.secret_keyring)
gpg.encoding = 'utf-8'
......@@ -206,6 +207,10 @@ def _default_gpghome():
return os.path.expanduser('~/.gnupg')
def _default_gpgbinary():
return os.getenv('GNUPG')
@contextlib.contextmanager
def _temp_dir():
"""Create a temporary directory, as a context manager."""
......@@ -230,7 +235,8 @@ def parse_public_key(public_key):
for p in 'pubring.gpg', 'secring.gpg':
with open(os.path.join(tmpdir, p), 'w') as fd:
pass
gpg = gnupg.GPG(homedir=tmpdir)
gpg = gnupg.GPG(binary=_default_gpgbinary(),
homedir=tmpdir)
gpg.encoding = 'utf-8'
return _import_one_key(gpg, public_key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment