Spade
Mini Shell
| Directory:~$ /proc/self/root/lib/python2.7/site-packages/certbot/_internal/ |
| [Home] [System Details] [Kill Me] |
�
���_c@s9dZddlmZddlZddlmZddlmZddlmZddlm Z ddl
mZdd l
mZdd
l
m
Z
ddlm Zeje�Zd�Zd�Zd
�Zd�Ze�Zd�Zd�ZgZd�Zd�Zd�Zd�Zd�Z
d�Z!d�Z"dS(s;Facilities for implementing hooks that call shell
commands.i����(tprint_functionN(tList(tSet(terrors(tutil(t
filesystem(tmisc(toscCsDt|jd�t|jd�t|jd�t|jd�dS(s#Check
hook commands are
executable.tpretposttdeploytrenewN(t
validate_hooktpre_hookt post_hooktdeploy_hookt
renew_hook(tconfig((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pytvalidate_hooksscCsBtj|�s2tj|�tj|�s2dSntjj|�S(s�Extract
the program run by a shell command.
:param str shell_cmd: command to be executed
:returns: basename of command or None if the command isn't found
:rtype: str or None
N(Rt
exe_existst plug_utiltpath_surgerytNoneRtpathtbasename(t shell_cmd((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyt_progs
cCs�|r�|jdd�d}t|�s�tjd}tjj|�r\dj||�}ndj|||�}tj |��q�ndS(s�Check
that a command provided as a hook is plausibly executable.
:raises .errors.HookCommandNotFound: if the command is not found
iitPATHs3{1}-hook command {0} exists, but is not
executable.s>Unable to find {2}-hook command {0} in the PATH.
(PATH is {1})N(
tsplitRRRtenvironRtexiststformatRtHookCommandNotFound(Rt hook_nametcmdRtmsg((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR*s
cCs_|jdkr?|jr?x$t|j�D]}t|�q(Wn|j}|r[t|�ndS(s�Run
pre-hooks if they exist and haven't already been run.
When Certbot is running with the renew subcommand, this function
runs any hooks found in the config.renewal_pre_hooks_dir (if they
have not already been run) followed by any pre-hook in the config.
If hooks in config.renewal_pre_hooks_dir are run and the pre-hook in
the config is a path to one of these scripts, it is not run twice.
:param configuration.NamespaceConfig config: Certbot settings
RN(tverbtdirectory_hookst
list_hookstrenewal_pre_hooks_dirt_run_pre_hook_if_necessaryR
(RthookR"((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR
<s cCs=|tkrtjd|�ntd|�tj|�dS(s�Run
the specified pre-hook if we haven't already.
If we've already run this exact command before, a message is
logged
saying the pre-hook was skipped.
:param str command: pre-hook to be run
s*Pre-hook command already run, skipping:
%sspre-hookN(texecuted_pre_hookstloggertinfot _run_hooktadd(tcommand((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR(Ts
cCsx|j}|jdkr^|jrHx$t|j�D]}t|�q1Wn|rtt|�qtn|rttd|�ndS(s�Run
post-hooks if defined.
This function also registers any executables found in
config.renewal_post_hooks_dir to be run when Certbot is used with
the renew subcommand.
If the verb is renew, we delay executing any post-hooks until
:func:`run_saved_post_hooks` is called. In this case, this function
registers all hooks found in config.renewal_post_hooks_dir to be
called followed by any post-hook in the config. If the post-hook in
the config is a path to an executable in the post-hook directory, it
is not scheduled to be run twice.
:param configuration.NamespaceConfig config: Certbot settings
Rs post-hookN(RR$R%R&trenewal_post_hooks_dirt_run_eventuallyR-(RR"R)((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyRds cCs
|tkrtj|�ndS(s�Registers a post-hook to be run eventually.
All commands given to this function will be run exactly once in the
order they were given when :func:`run_saved_post_hooks` is called.
:param str command: post-hook to register to be run
N(t
post_hookstappend(R/((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR1�s cCs"xtD]}td|�qWdS(sGRun
any post hooks that were saved up in the course of the 'renew'
verbs post-hookN(R2R-(R"((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pytrun_saved_post_hooks�s
cCs)|jr%t|j|||j�ndS(sRun
post-issuance hook if defined.
:param configuration.NamespaceConfig config: Certbot settings
:param domains: domains in the obtained certificate
:type domains: `list` of `str`
:param str lineage_path: live directory path for the new cert
N(Rt_run_deploy_hooktdry_run(Rtdomainstlineage_path((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR�s cCs�t�}|jrRx=t|j�D])}t||||j�|j|�q"Wn|jr�|j|kr�tj d|j�q�t|j|||j�ndS(s]Run
post-renewal hooks.
This function runs any hooks found in
config.renewal_deploy_hooks_dir followed by any renew-hook in the
config. If the renew-hook in the config is a path to a script in
config.renewal_deploy_hooks_dir, it is not run twice.
If Certbot is doing a dry run, no hooks are run and messages are
logged saying that they were skipped.
:param configuration.NamespaceConfig config: Certbot settings
:param domains: domains in the obtained certificate
:type domains: `list` of `str`
:param str lineage_path: live directory path for the new cert
s0Skipping deploy-hook '%s' as it was already run.N(
tsetR%R&trenewal_deploy_hooks_dirR5R6R.RR+R,(RR7R8texecuted_dir_hooksR)((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR�s
cCsN|rtjd|�dSdj|�tjd<|tjd<td|�dS(sRun
the specified deploy-hook (if not doing a dry run).
If dry_run is True, command is not run and a message is logged
saying that it was skipped. If dry_run is False, the hook is run
after setting the appropriate environment variables.
:param str command: command to run as a deploy-hook
:param domains: domains in the obtained certificate
:type domains: `list` of `str`
:param str lineage_path: live directory path for the new cert
:param bool dry_run: True iff Certbot is doing a dry run
s)Dry run: skipping deploy hook command: %sNt
tRENEWED_DOMAINStRENEWED_LINEAGEsdeploy-hook(R+twarningtjoinRRR-(R/R7R8R6((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR5�s
cCs(tj||dtj��\}}|S(s�Run
a hook command.
:param str cmd_name: the user facing name of the hook being run
:param shell_cmd: shell command to execute
:type shell_cmd: `list` of `str` or `str`
:returns: stderr if there was
anytenv(Rtexecute_commandRtenv_no_snap_for_external_calls(tcmd_nameRterrt_((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR-�s$csa�fd�tj��D�}g|D]+}tj|�r&|jd�r&|^q&}t|�S(s�List
paths to all hooks found in dir_path in sorted order.
:param str dir_path: directory to search
:returns: `list` of `str`
:rtype: sorted list of absolute paths to executables in dir_path
c3s$|]}tjj�|�VqdS(N(RRR@(t.0tf(tdir_path(s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pys <genexpr>�st~(RtlistdirRt
is_executabletendswithtsorted(RItallpathsRthooks((RIs;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyR&�s 8(#t__doc__t
__future__Rtloggingtacme.magic_typingRRtcertbotRRtcertbot.compatRRRtcertbot.pluginsRt getLoggert__name__R+RRRR
R9R*R(RR2R1R4RRR5R-R&(((s;/usr/lib/python2.7/site-packages/certbot/_internal/hooks.pyt<module>s4