Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
898c372f
Commit
898c372f
authored
Oct 21, 2012
by
Clément Schreiner
Browse files
Fix the adding/removing of signatures.
(+ add generic exception for missing data in a gpg command)
parent
b21c1495
Changes
1
Hide whitespace changes
Inline
Side-by-side
debexpo/lib/gnupg.py
View file @
898c372f
...
...
@@ -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
,
filenam
e
,
pubring
=
None
):
def
add_signature
(
self
,
data
=
None
,
path
=
Non
e
,
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment