�
�S�g$ � �x � d Z ddlmZ ddlZddlZddlZddlZddlmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ dd lmZ dd
lmZ ddlmZ dZ ej2 e� Zerg d�ng Zd$d�Zd$d�Zdedee de fd�Z!dddd�Z"dddd�Z#de de fd�Z$de de fd�Z% d%d e d!e d"ee& de e'e e f fd#�Z(y# e$ r d
ZY �lw xY w)&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_HANDLEFT)z /usr/sbinz/usr/local/binz/usr/local/sbin�returnc �j � t s-t j � dk( rt j d� �yy)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�
shellwin32�
IsUserAnAdminr �Error� � ��/build/snapcraft-certbot-29b1212f749eeba2f1dece1adfe9a83a/parts/certbot/install/lib/python3.12/site-packages/certbot/compat/misc.py�+raise_for_non_administrative_windows_rightsr ! s. � � �*�2�2�4��9��l�l�^�_�_� :�:r c �� � t ryd} t t � }|r#|j |j � | z � yy# t
$ r t j dd�� Y yw xY w)zR
On Windows, ensure that Console Virtual Terminal Sequences are enabled.
N� zFailed to set console modeT)�exc_info)r r
r �SetConsoleMode�GetConsoleMode�
pywinerror�logger�debug)�"ENABLE_VIRTUAL_TERMINAL_PROCESSING�hs r �prepare_virtual_consoler , sj � �
�� *0�&�B��*�+���
���Q�-�-�/�2T�T�U�
��� B����1�D��A�B�s �3A � A#�"A#�timeout�promptc �> � t j t j gg g | � \ }}}|s0t j dj |r
|� � �d� � �|d j
� S # t $ r! t j j
� cY S w xY w)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 )�select�sys�stdinr r �format�readline�OSError)r! r" |