def gpg_stash_key( appname, key_bin, config_dir=None, gpghome=None ):
    """
    Store a key locally to our app keyring.
    Does NOT put it into a blockchain ID
    Return the key ID on success
    Return None on error
    """

    assert is_valid_appname(appname)
    key_bin = str(key_bin)
    assert len(key_bin) > 0

    if gpghome is None:
        config_dir = get_config_dir( config_dir )
        keydir = make_gpg_home( appname, config_dir=config_dir )
    else:
        keydir = gpghome

    gpg = gnupg.GPG( homedir=keydir )
    res = gpg.import_keys( key_bin )

    try:
        assert res.count == 1, "Failed to store key (%s)" % res
    except AssertionError, e:
        log.exception(e)
        log.error("Failed to store key to %s" % keydir)
        log.debug("res: %s" % res.__dict__)
        log.debug("(%s)\n%s" % (len(key_bin), key_bin))
        return None

    return res.fingerprints[0]
def gpg_stash_key ( appname , key_bin , config_dir = None , gpghome = None ) : assert is_valid_appname ( appname ) key_bin = str ( key_bin ) assert len ( key_bin ) > 0 if gpghome is None : config_dir = get_config_dir ( config_dir ) keydir = make_gpg_home ( appname , config_dir = config_dir ) else : keydir = gpghome gpg = gnupg . GPG ( homedir = keydir ) res = gpg . import_keys ( key_bin ) try : assert res . count == 1 , "Failed to store key (%s)" % res except AssertionError , e : log . exception ( e ) log . error ( "Failed to store key to %s" % keydir ) log . debug ( "res: %s" % res . __dict__ ) log . debug ( "(%s)\n%s" % ( len ( key_bin ) , key_bin ) ) return None return res . fingerprints [ 0 ]
Store a key locally to our app keyring.
    Does NOT put it into a blockchain ID
    Return the key ID on success
    Return None on error