a ‚oezã@s"dZddlZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd l m Z dd lmZdd lmZzdd lmZdd lmZWney¶eZeZYn0ddddddddœZe e¡Zeeeedœdd„ZGdd„deƒZGdd„deƒZGdd„de ƒZ dS)z0Module configuring Certbot in a snap environmentéN)ÚIterable)ÚList)ÚOptional)ÚSession)Ú HTTPAdapter)Ú HTTPError)ÚRequestException)Úos)ÚError)ÚHTTPConnection)ÚHTTPConnectionPoolzaarch64-linux-gnuzarm-linux-gnueabihfzi386-linux-gnuzpowerpc64le-linux-gnuzpowerpc-linux-gnuzx86_64-linux-gnuzs390x-linux-gnu)Zarm64ZarmhfZi386Zppc64elZpowerpcZamd64Zs390x)Úcli_argsÚreturnc Cs2tj d¡}|tvr"td |¡ƒ‚d tj d¡t|¡tjd<tƒ˜}| dtƒ¡z|jddd }|  ¡Wn^t yÎ}zFt |t ƒr¬|j jd kr¬t d ¡t d ¡n t d ¡|‚WYd}~n d}~00Wdƒn1sä0Y| ¡}dd„| di¡ dg¡Dƒ}d |¡tjd<| d¡|S)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 Z SNAP_ARCHz$Unrecognized value of SNAP_ARCH: {0}z{0}/usr/lib/{1}/libaugeas.so.0ZSNAPZCERTBOT_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.NcSsJg|]B}| di¡ d¡dkr| di¡ d¡dkrd |dd¡‘qS)ZplugZpluginz plug-attrsZcontentz certbot-1z./snap/{0}/current/lib/python3.8/site-packages/ZslotZsnap)ÚgetÚformat)Ú.0Úitem©rú>C:\Program Files\Certbot\pkgs\certbot\_internal\snap_config.pyÚ Hsýzprepare_env..ÚresultZ establishedú:ZCERTBOT_PLUGIN_PATHz--preconfigured-renewal)r ÚenvironrÚ_ARCH_TRIPLET_MAPr rrZmountÚ _SnapdAdapterZraise_for_statusrÚ isinstancerÚresponseZ status_codeÚLOGGERÚerrorZjsonÚjoinÚappend)r Z snap_archZsessionrÚeÚdataZ connectionsrrrÚ prepare_env&s4 ÿ ÿ    8ÿ r$cs0eZdZddœ‡fdd„ Zddœdd„Z‡ZS)Ú_SnapdConnectionN©rcstƒ d¡d|_dS©NZ localhost)ÚsuperÚ__init__Úsock©Úself©Ú __class__rrr)Us z_SnapdConnection.__init__cCs"t tjtj¡|_|j d¡dS)Nz/run/snapd.socket)ÚsocketZAF_UNIXZ SOCK_STREAMr*Úconnectr+rrrr0Ysz_SnapdConnection.connect)Ú__name__Ú __module__Ú __qualname__r)r0Ú __classcell__rrr-rr%Tsr%cs0eZdZddœ‡fdd„ Zedœdd„Z‡ZS)Ú_SnapdConnectionPoolNr&cstƒ d¡dSr')r(r)r+r-rrr)_sz_SnapdConnectionPool.__init__cCstƒS©N)r%r+rrrÚ _new_connbsz_SnapdConnectionPool._new_conn)r1r2r3r)r%r7r4rrr-rr5^sr5c@s(eZdZdeeeeedœdd„ZdS)rN)ÚurlÚproxiesrcCstƒSr6)r5)r,r8r9rrrÚget_connectiongsz_SnapdAdapter.get_connection)N)r1r2r3Ústrrrr5r:rrrrrfsÿ ÿr)!Ú__doc__Zloggingr/ÚtypingrrrZrequestsrZrequests.adaptersrZrequests.exceptionsrrZcertbot.compatr Zcertbot.errorsr Zurllib3.connectionr Zurllib3.connectionpoolr Ú ImportErrorÚobjectrZ getLoggerr1rr;r$r%r5rrrrrÚs<            ù .