U
    ÝÁ]r  ã                   @   s´   d Z ddlmZ ddlZddlZzddlmZ dZW n e	k
rL   dZY nX ddl
mZ ddlmZ ertd	d
dgng Zdd„ Zdd„ ZddddœZddddœZdd„ Zdd„ ZdS )zk
This compat module handles various platform specific calls that do not fall into one
particular category.
é    )Úabsolute_importN)ÚshellFT)Úerrors)Úosz	/usr/sbinz/usr/local/binz/usr/local/sbinc                   C   s   t st ¡ dkrt d¡‚dS )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.
    r   zAError, certbot must be run on a shell with administrative rights.N)Ú
POSIX_MODEÚ
shellwin32ZIsUserAnAdminr   ÚError© r	   r	   ú5/usr/lib/python3/dist-packages/certbot/compat/misc.pyÚ+raise_for_non_administrative_windows_rights   s    r   c                 C   s`   z<t   tjgg g | ¡\}}}|s0t d |¡¡‚|d  ¡ W S  tk
rZ   tj ¡  Y S X dS )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}'r   N)ÚselectÚsysÚstdinr   r   ÚformatÚreadlineÚOSError)ZtimeoutÚpromptZrlistÚ_r	   r	   r
   Úreadline_with_timeout$   s    ÿr   z
C:\CertbotzC:\Certbot\libzC:\Certbot\log)ZconfigZworkZlogsz/etc/letsencryptz/var/lib/letsencryptz/var/log/letsencryptc                 C   s   t jdkrt|  S t|  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)Zfolder_typer	   r	   r
   Úget_default_folderN   s    
r   c                 C   s.   t jdkr| S t j | ¡\}}|| dd¡ 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   )r   r   ÚpathÚ
splitdriveÚreplace)r   ZdriveÚtailr	   r	   r
   Ú.underscores_for_unsupported_characters_in_path`   s    
r   )Ú__doc__Z
__future__r   r   r   Zwin32com.shellr   r   r   ÚImportErrorZcertbotr   Zcertbot.compatr   ZSTANDARD_BINARY_DIRSr   r   r   r   r   r   r	   r	   r	   r
   Ú<module>   s.   
ýý