ok

Mini Shell

Direktori : /lib/python3.6/site-packages/certbot/compat/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/certbot/compat/__pycache__/misc.cpython-36.pyc

3

گa��@s�dZddlmZddlZddlZddlZddlZddlmZddlm	Z	ddl
Z
ddlmZddl
mZy8ddlmZdd	lmZdd
lmZddlmZdZWnek
r�d
ZYnXeje�Zer�dddgngZdd�dd�Zdd�dd�Ze ee!e!d�dd�Z"dddd�Z#dddd�Z$e!e!d �d!d"�Z%e!e!d#�d$d%�Z&d+e!e!ee'e	e(e!e!fd&�d'd(�Z)d,e!e!ee'e	e!e!fd&�d)d*�Z*dS)-zk
This compat module handles various platform specific calls that do not fall into one
particular category.
�)�absolute_importN)�Optional)�Tuple)�errors)�os)�error)�shell)�GetStdHandle)�STD_OUTPUT_HANDLEFTz	/usr/sbinz/usr/local/binz/usr/local/sbin)�returncCs trtj�dkrtjd��dS)z�
    On Windows, raise if current shell does not have the administrative rights.
    Do nothing on Linux.

    :raises .errors.Error: If the current shell does not have administrative rights on Windows.
    rzAError, certbot must be run on a shell with administrative rights.N)�
POSIX_MODE�
shellwin32Z
IsUserAnAdminr�Error�rr�/usr/lib/python3.6/misc.py�+raise_for_non_administrative_windows_rights"srcCsVtrdSd}y"tt�}|r,|j|j�|B�Wn"tk
rPtjddd�YnXdS)zR
    On Windows, ensure that Console Virtual Terminal Sequences are enabled.

    N�zFailed to set console modeT)�exc_info)rr	r
ZSetConsoleModeZGetConsoleMode�
pywinerror�logger�debug)Z"ENABLE_VIRTUAL_TERMINAL_PROCESSING�hrrr�prepare_virtual_console-sr)�timeout�promptrcCsbyBtjtjggg|�\}}}|s8tjdj|r0|nd���|dj�Stk
r\tjj�SXdS)a(
    Read user input to return the first line entered, or raise after specified timeout.

    :param float timeout: The timeout in seconds given to the user.
    :param str prompt: The prompt message to display to the user.

    :returns: The first line entered by the user.
    :rtype: str

    z,Timed out waiting for answer to prompt '{0}'�rN)�select�sys�stdinrr�format�readline�OSError)rrZrlist�_rrr�readline_with_timeoutAsr#z
C:\CertbotzC:\Certbot\libzC:\Certbot\log)�configZworkZlogsz/etc/letsencryptz/var/lib/letsencryptz/var/log/letsencrypt)�folder_typercCstjdkrt|St|S)z�
    Return the relevant default folder for the current OS

    :param str folder_type: The type of folder to retrieve (config, work or logs)

    :returns: The relevant default folder.
    :rtype: str

    �nt)r�name�LINUX_DEFAULT_FOLDERS�WINDOWS_DEFAULT_FOLDERS)r%rrr�get_default_folderjs

r*)�pathrcCs.tjdkr|Stjj|�\}}||jdd�S)z�
    Replace unsupported characters in path for current OS by underscores.
    :param str path: the path to normalize
    :return: the normalized path
    :rtype: str
    r&�:r")rr'r+�
splitdrive�replace)r+Zdrive�tailrrr�.underscores_for_unsupported_characters_in_path{s
r0)�cmd_name�	shell_cmd�envrc	Csntjd||�tr0tj|dtjtjdd|d�}n$dd|g}tj|tjtjdd|d�}|j|j}}|j||fS)a;
    Run a command:
        - on Linux command will be run by the standard shell selected with
          subprocess.run(shell=True)
        - on Windows command will be run in a Powershell shell

    This differs from execute_command: it returns the exit code, and does not log the result
    and output of the command.

    :param str cmd_name: the user facing name of the hook being run
    :param str shell_cmd: shell command to execute
    :param dict env: environ to pass into subprocess.run

    :returns: `tuple` (`int` returncode, `str` stderr, `str` stdout)
    zRunning %s command: %sTF)r�stdout�stderr�universal_newlines�checkr3zpowershell.exez-Command)r4r5r6r7r3)	r�infor�
subprocessZrun�PIPEr4r5�
returncode)r1r2r3�proc�line�out�errrrr�execute_command_status�s
r@cCs~tjdt�t|||�\}}}tjj|jdd�d�}|rJtj	d|||�|dkrbtj
d|||�|rvtj
d|||�||fS)a)
    Run a command:
        - on Linux command will be run by the standard shell selected with
          subprocess.run(shell=True)
        - on Windows command will be run in a Powershell shell

    This differs from execute_command: it returns the exit code, and does not log the result
    and output of the command.

    :param str cmd_name: the user facing name of the hook being run
    :param str shell_cmd: shell command to execute
    :param dict env: environ to pass into subprocess.run

    :returns: `tuple` (`str` stderr, `str` stdout)
    zTexecute_command will be deprecated in the future, use execute_command_status insteadN�rzOutput from %s command %s:
%sz&%s command "%s" returned error code %dz#Error output from %s command %s:
%s)�warnings�warn�PendingDeprecationWarningr@rr+�basename�splitrr8r)r1r2r3r;r?r>Zbase_cmdrrr�execute_command�s
rG)N)N)+�__doc__Z
__future__rZloggingrr9rZtypingrrrBZcertbotrZcertbot.compatrZ
pywintypesrrZwin32com.shellrr
Zwin32consoler	r
r�ImportErrorZ	getLogger�__name__rZSTANDARD_BINARY_DIRSrr�float�strr#r)r(r*r0�dict�intr@rGrrrr�<module>sB

$!

Zerion Mini Shell 1.0