summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Heinlein <devel@glatzor.de>2012-06-01 06:37:51 +0200
committerSebastian Heinlein <devel@glatzor.de>2012-06-01 06:37:51 +0200
commitfdae874a77c122a72d283fc13c5494b0359f6b67 (patch)
treec2fa97fd41b7586dccdc3d267f25a471c296f18a
parent1b18197f00a0f8b230c11dd90b6f9799ac114d55 (diff)
downloadpython-apt-fdae874a77c122a72d283fc13c5494b0359f6b67.tar.gz
Add an export_key method
-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.