Download a GPG key from a key server.
    Do not import it into any keyrings.
    Return the ASCII-armored key

def gpg_download_key( key_id, key_server, config_dir=None ):
    """
    Download a GPG key from a key server.
    Do not import it into any keyrings.
    Return the ASCII-armored key
    """

    config_dir = get_config_dir( config_dir )
    tmpdir = make_gpg_tmphome( prefix="download", config_dir=config_dir )
    gpg = gnupg.GPG( homedir=tmpdir )
    recvdat = gpg.recv_keys( key_server, key_id )
    fingerprint = None

    try:
        assert recvdat.count == 1
        assert len(recvdat.fingerprints) == 1
        fingerprint = recvdat.fingerprints[0]

    except AssertionError, e:
        log.exception(e)
        log.error( "Failed to fetch key '%s' from '%s'" % (key_id, key_server))
        shutil.rmtree( tmpdir )
        return None

    keydat = gpg.export_keys( [fingerprint] )
    shutil.rmtree( tmpdir )
    return str(keydat)