summaryrefslogtreecommitdiff
path: root/apt/auth.py
diff options
context:
space:
mode:
Diffstat (limited to 'apt/auth.py')
-rw-r--r--apt/auth.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/apt/auth.py b/apt/auth.py
index d6b1d97f..3b15b256 100644
--- a/apt/auth.py
+++ b/apt/auth.py
@@ -179,6 +179,26 @@ def remove_key(fingerprint, wait=True):
else:
return proc
+def export_key(fingerprint, wait=True):
+ """Return the GnuPG key in text format.
+
+ Keyword arguments:
+ fingerprint -- the fingerprint identifying the key
+ wait -- if the system should be blocked until the internal GnuPG is
+ completed. Otherwise the subprocess.Popen() instance will be
+ returned. By default the call will be blocking.
+ """
+ cmd = _get_gpg_command()
+ cmd.extend(["--armor", "--export", fingerprint])
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
+ if wait:
+ _wait_and_raise(proc)
+ return proc.stdout.read()
+ else:
+ return proc
+
def list_keys():
"""Returns a list of TrustedKey instances for each key which is
used to trust repositories.