Ë
    M/Åez  ã                   óR  — d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ 	 ddlmZ ddlmZ ddddddddœZ ej2                  e«      Zdee   dee   fd„Z G d„ de«      Z G d„ de«      Z G d„ de
«      Z y# e$ r eZeZY ŒWw xY w)z0Module configuring Certbot in a snap environmenté    N)ÚIterable)ÚList)ÚOptional)ÚSession)ÚHTTPAdapter)Ú	HTTPError)ÚRequestException)Úos)ÚError)ÚHTTPConnection)ÚHTTPConnectionPoolzaarch64-linux-gnuzarm-linux-gnueabihfzi386-linux-gnuzpowerpc64le-linux-gnuzpowerpc-linux-gnuzx86_64-linux-gnuzs390x-linux-gnu)Úarm64ÚarmhfÚi386Úppc64elÚpowerpcÚamd64Ús390xÚcli_argsÚreturnc                 óv  — t         j                  j                  d«      }|t        vrt	        dj                  |«      «      ‚dj                  t         j                  j                  d«      t        |   «      t         j                  d<   t        «       5 }|j                  dt        «       «       	 |j                  dd¬	«      }|j                  «        	 ddd«       j#                  «       }|j                  di «      j                  dg «      D �cg c]a  }|j                  di «      j                  d«      dk(  r;|j                  di «      j                  d«      dk(  rdj                  |d   d   «      ‘Œc }}dj%                  |«      t         j                  d<   | j'                  d«       | S # t        $ rq}t        |t        «      rE|j                  j                  d
k(  r,t        j!                  d«       t        j!                  d«       |‚t        j!                  d«       |‚d}~ww xY w# 1 sw Y   �ŒXxY wc c}w )zÃ
    Prepare runtime environment for a certbot execution in snap.
    :param list cli_args: List of command line arguments
    :return: Update list of command line arguments
    :rtype: list
    Ú	SNAP_ARCHz$Unrecognized value of SNAP_ARCH: {0}z{0}/usr/lib/{1}/libaugeas.so.0ÚSNAPÚCERTBOT_AUGEAS_PATHzhttp://snapd/z:http://snapd/v2/connections?snap=certbot&interface=contentg      >@)Útimeouti”  zYAn error occurred while fetching Certbot snap plugins: your version of snapd is outdated.z[Please run "sudo snap install core; sudo snap refresh core" in your terminal and try again.z^An error occurred while fetching Certbot snap plugins: make sure the snapd service is running.NÚresultÚestablishedÚplugÚpluginz
plug-attrsÚcontentz	certbot-1z./snap/{0}/current/lib/python3.8/site-packages/ÚslotÚsnapú:ÚCERTBOT_PLUGIN_PATHz--preconfigured-renewal)r
   ÚenvironÚgetÚ_ARCH_TRIPLET_MAPr   Úformatr   ÚmountÚ_SnapdAdapterÚraise_for_statusr	   Ú
isinstancer   ÚresponseÚstatus_codeÚLOGGERÚerrorÚjsonÚjoinÚappend)r   Ú	snap_archÚsessionr-   ÚeÚdataÚitemÚconnectionss           ú?/usr/lib/python3/dist-packages/certbot/_internal/snap_config.pyÚprepare_envr;   &   sü  € ô —
‘
—‘˜{Ó+€IàÔ)Ñ)ÜÐ:×AÑAÀ)ÓLÓMÐMà(H×(OÑ(OÜ
�
‰
�‰�vÓÔ 1°)Ñ <ó)>„B‡J�JÐ$Ñ%ô 
‹ð �gØ�‰�o¤}£Ô7ð	Ø—{‘{Ð#_Ø+/ð #ó 1ˆHà×%Ñ%Õ'÷ð$ �=‰=‹?€Dà#Ÿx™x¨°"Ó5×9Ñ9¸-ÈÓLöQØØ—h‘h˜v rÓ*×.Ñ.¨vÓ6¸(ÒBØ—x‘x ¨bÓ1×5Ñ5°iÓ@ÀKÒOð D×JÑJÈ4ÐPVÉ<ÐX^ÑK_Õ`ð Q€Kð Qð
 ),¯©°Ó(=„B‡J�JÐ$Ñ%à‡O�OÐ-Ô.à€Oøô+  ò 		Ü˜!œYÔ'¨A¯J©J×,BÑ,BÀcÒ,IÜ—‘ð Bô Cä—‘ð ?ô @ð
 ˆGô —‘ð Gô HàˆGûð		ú÷ñ üò&Qs2   ÂH)Â/#F,ÄA&H6Æ,	H&Æ5A,H!È!H&È&H)È)H3c                   ó(   ‡ — e Zd Zdˆ fd„Zdd„Zˆ xZS )Ú_SnapdConnectionc                 ó2   •— t         ‰| �  d«       d | _        y ©NÚ	localhost)ÚsuperÚ__init__Úsock©ÚselfÚ	__class__s    €r:   rB   z_SnapdConnection.__init__U   s   ø€ Ü‰Ñ˜Ô%Ø-1ˆ�	ó    c                 ó¨   — t        j                   t         j                  t         j                  «      | _        | j                  j	                  d«       y )Nz/run/snapd.socket)ÚsocketÚAF_UNIXÚSOCK_STREAMrC   Úconnect©rE   s    r:   rL   z_SnapdConnection.connectY   s1   € Ü—M‘M¤&§.¡.´&×2DÑ2DÓEˆŒ	Ø�	‰	×ÑÐ-Õ.rG   ©r   N)Ú__name__Ú
__module__Ú__qualname__rB   rL   Ú__classcell__©rF   s   @r:   r=   r=   T   s   ø„ õ2÷/rG   r=   c                   ó,   ‡ — e Zd Zdˆ fd„Zdefd„Zˆ xZS )Ú_SnapdConnectionPoolr   c                 ó$   •— t         ‰| �  d«       y r?   )rA   rB   rD   s    €r:   rB   z_SnapdConnectionPool.__init___   s   ø€ Ü‰Ñ˜Õ%rG   c                 ó   — t        «       S ©N)r=   rM   s    r:   Ú	_new_connz_SnapdConnectionPool._new_connb   s   € ÜÓ!Ð!rG   rN   )rO   rP   rQ   rB   r=   rY   rR   rS   s   @r:   rU   rU   ^   s   ø„ õ&ð"Ð+÷ "rG   rU   c                   ó0   — e Zd Z	 ddedeee      defd„Zy)r*   NÚurlÚproxiesr   c                 ó   — t        «       S rX   )rU   )rE   r[   r\   s      r:   Úget_connectionz_SnapdAdapter.get_connectiong   s   € ä#Ó%Ð%rG   rX   )rO   rP   rQ   Ústrr   r   rU   r^   © rG   r:   r*   r*   f   s*   „ à:>ñ& #ð &Ø (¨°#©Ñ 7ð&ØCWô&rG   r*   )!Ú__doc__ÚloggingrI   Útypingr   r   r   Úrequestsr   Úrequests.adaptersr   Úrequests.exceptionsr   r	   Úcertbot.compatr
   Úcertbot.errorsr   Úurllib3.connectionr   Úurllib3.connectionpoolr   ÚImportErrorÚobjectr'   Ú	getLoggerrO   r/   r_   r;   r=   rU   r*   r`   rG   r:   ú<module>rn      sÅ   ðÙ 6Û Û Ý Ý Ý å Ý )Ý )Ý 0å Ý  ð Ý1Ý9ð !Ø"ØØ&Ø"ØØñÐ ð 
ˆ×	Ñ	˜8Ó	$€ð+˜$˜s™)ð +¨¨S©	ó +ô\/�~ô /ô"Ð-ô "ô&�Kõ &øðg ò  à€NØÒð ús   ÁB Â	B&Â%B&