From fdae874a77c122a72d283fc13c5494b0359f6b67 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Fri, 1 Jun 2012 06:37:51 +0200 Subject: Add an export_key method --- apt/auth.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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. -- cgit v1.2.3