fzdZddlZddlZddlmZej eZgdZdZ dZ d dZ d dZ d Z d d Zy)z0gpg.py - Collection of gpg key related functionsN)subp)gpgz--with-fingerprintz--no-default-keyringz --list-keysz --keyringc tjddd|gd\}}|S#tj$r$}tjd||d}Yd}~|Sd}~wwxYw)z*Export gpg key, armoured key gets returnedrz--exportz--armourTcapture&Failed to export armoured key "%s": %sN)rProcessExecutionErrorLOGdebug)keyarmour_errors //usr/lib/python3/dist-packages/cloudinit/gpg.py export_armourrsaii J C 0$  M  % % :CG M s"AAAcJtjddg|djS)z~Dearmor gpg key, dearmored key gets returned note: man gpg(1) makes no mention of an --armour spelling, only --armor rz --dearmorF)datadecode)rstdout)r s rdearmorr's" 99e[)E B I IIcg}|jt|s|jd|j|tj|d\}}|rtj d|||S)zList keys from a keyring with fingerprints. Default to a stable machine parseable format. @param key_file: a string containing a filepath to a key @param human_output: return output intended for human parsing z --with-colonsTrr)extendGPG_LISTappendrr warning)key_file human_outputcmdrstderrs rlistr!/s^ CJJx  ?#JJxyyd3VV   Iw =t   % %> 0#u==>sAAAct|}|s' t||t|} t ||S|S#t$rtj d|wxYw#t |wxYw)zget gpg keyid from keyserver)r+zFailed to obtain gpg key %s)rr1r*r exceptionr3)keyidr+r s r getkeybyidr7}si 5 !F   Ui 0"5)F u  M6M  MM7 ?   u s7!AA A()F))r#r#)zkeyserver.ubuntu.com)__doc__loggingr' cloudinitr getLogger__name__r rrrr!r1r3r7rrr>sL7 g!  J&.b>r