Commit 898c372f authored by Clément Schreiner's avatar Clément Schreiner
Browse files

Fix the adding/removing of signatures.

(+ add generic exception for missing data in a gpg command)
parent b21c1495
......@@ -100,6 +100,9 @@ class GpgVerifyInvalidData(Exception):
class GpgFailure(Exception):
""" Generic exception for errors while running gnupg """
class GpgMissingData(Exception):
""" Some data is missing for the gpg command. """
#
# Main class
......@@ -250,19 +253,27 @@ class GnuPG(object):
else:
return GpgKeyBlock(None, None)
def add_signature(self, filename, pubring=None):
def add_signature(self, data=None, path=None, pubring=None):
"""
Adds a key's signature to the public keyring.
Returns the triple (stdout, stderr, return code).
Returns the triple GpgResult(code, stdout, stderr).
"""
args = ('--import-options', 'import-minimal', '--import', filename)
(out, err, code) = self._run(args=args, pubring=pubring)
args = ('--import-options', 'import-minimal', '--import')
stdin = None
if data is not None:
stdin = data
elif path is not None:
args.append(path)
else:
raise GpgMissingData
(out, err, code) = self._run(stdin=stdin, args=args, pubring=pubring)
return GpgResult(code, out, err)
def remove_signature(self, keyid, pubring=None):
"""
Removes a signature from the public keyring
Returns the triple (stdout, stderr, return code).
Returns the triple GpgResult(code, stdout, stderr).
"""
args = ('--yes', '--delete-key', keyid)
(out, err, code) = self._run(args=args, pubring=pubring)
......
Supports Markdown
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