← Back
Editing: util.cpython-38.pyc
U �]\L � @ sD d Z ddlZddlZddlZddlmZ ddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlmZmZ ddlmZ ddlmZ ddlmZ ddlmZ dd lmZ e j �d �r�ddlZdZndZe�e�Z e�!d d�Z"e�!dd�Z#dZ$dZ%dZ&ej'�(d�Z)e�*� Z+e� Z,e j-fdd�Z.dd� Z/dd� Z0dd� Z1dd� Z2dUd d!�Z3dVd#d$�Z4d%d&� Z5dWd(d)�Z6dXd+d,�Z7d-d.� Z8d/d0� Z9d1d2� Z:d3d4� Z;d5d6� Z<d7d8� Z=dYd:d;�Z>d<d=� Z?dZd>d?�Z@e �Ad@�ZBdAdB� ZCG dCdD� dDejD�ZEdEdF� ZFdGdH� ZGdIdJ� ZHdKdL� ZIdMdN� ZJdOdP� ZKdQdR� ZLdSdT� ZMdS )[zUtilities for all Certbot.� N)�OrderedDict)�Tuple�Union)� constants)�errors)�lock)�os)� filesystem�linuxTF�Keyzfile pem�CSRzfile data formz[1mz[31mz[0m)z$The following error was encountered:z{0}zWEither run as root, or set --config-dir, --work-dir, and --logs-dir to writeable paths.c C s� zt j| t jt jdd�}W n8 ttfk rR dd�| � }||� t�|��Y nX |�� \}}|j dkr�dd�| �||f }||� t�|��||fS )z�Run the script with the given params. :param list params: List of parameters to pass to Popen :param callable log: Logger method to use for errors T)�stdout�stderr�universal_newlineszUnable to run the command: %s� r zError while running %s. %s %s) � subprocess�Popen�PIPE�OSError� ValueError�joinr ZSubprocessError�communicate� returncode)Zparams�log�proc�msgr r � r �./usr/lib/python3/dist-packages/certbot/util.py� run_scriptC s( � � r c C sT t j�| �\}}|rt�| �S t jd �t j�D ]}t�t j�|| ��r0 dS q0dS )z�Determine whether path/name refers to an executable. :param str exe: Executable path or name :returns: If exe is a valid executable :rtype: bool �PATHTF)r �path�splitr Z is_executable�environ�pathsepr )�exer �_r r r � exe_existsa s r&