403Webshell
Server IP : 35.236.43.222  /  Your IP : 216.73.216.143
Web Server : Apache
System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64
User : deploy ( 1002)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/certbot/display/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/certbot/display/__pycache__/util.cpython-39.pyc
a

�`f[�@sdZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZddlm
Z
ddlmZddlmZdd	lmZe�e�Zd
ZdZdZd
ZdZdZdd�Zd#dd�Zdd�Zej� ej!�Gdd�de"��Z#dd�Z$ej� ej!�Gdd�de"��Z%dd�Z&dd �Z'd!d"�Z(dS)$a$Certbot display.

This module (`certbot.display.util`) or its companion `certbot.display.ops`
should be used whenever:

- Displaying status information to the user on the terminal
- Collecting information from the user via prompts

Other messages can use the `logging` module. See `log.py`.

�N)�List)�errors)�
interfaces)�	constants)�	completer)�misc)�os�H�okZcancel�helpZesczO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -c	Cs8|��}g}|D]}|�tj|dddd��qd�|�S)z�Format lines nicely to 80 chars.

    :param str msg: Original message

    :returns: Formatted message respecting newlines in message
    :rtype: str

    �PF)Zbreak_long_wordsZbreak_on_hyphens�
)�
splitlines�append�textwrapZfill�join)�msg�linesZfixed_l�line�r�6/usr/lib/python3/dist-packages/certbot/display/util.py�_wrap_lines1s	�
r���@cCs8|rtj�|�tj��t�||�}|s.t�|�d�S)aGet user input with a timeout.

    Behaves the same as six.moves.input, however, an error is raised if
    a user doesn't answer after timeout seconds. The default timeout
    value was chosen to place it just under 12 hours for users following
    our advice and running Certbot twice a day.

    :param str prompt: prompt to provide for input
    :param float timeout: maximum number of seconds to wait for input

    :returns: user response
    :rtype: str

    :raises errors.Error if no answer is given before the timeout

    r
)�sys�stdout�write�flushrZreadline_with_timeout�EOFError�rstrip)�promptZtimeoutrrrr�input_with_timeoutGs
r cCs tj�tj�j|dddd�dS)zMDisplay a basic status message.

    :param str msg: message to display

    F)�pause�decorate�wrapN)�zopeZ	componentZ
getUtilityr�IDisplay�notification)rrrr�notifyes�r'cs�eZdZdZ�fdd�Zddd�Zd d	d
�Zd!dd�Zd"dd�Zd#dd�Z	dd�Z
dd�Zd$dd�Zdd�Z
dd�Zdd�Z�ZS)%�FileDisplayzFile-based display.cs$tt|���||_||_d|_dS)NF)�superr(�__init__�outfile�force_interactive�skipped_interaction)�selfr+r,��	__class__rrr*vszFileDisplay.__init__TFcCsz|rt|�}t�d|�|j�|r&dndd|r4dndjtjt|d��|j�	�|rv|�
|�rltd�n
t�d�d	S)
aDisplays a notification and waits for user acceptance.

        :param str message: Message to display
        :param bool pause: Whether or not the program should pause for the
            user's confirmation
        :param bool wrap: Whether or not the application should wrap text
        :param bool force_interactive: True if it's safe to prompt the user
            because it won't cause any workflow regressions
        :param bool decorate: Whether to surround the message with a
            decorated frame

        �Notifying user: %s�{line}{frame}{line}��{msg}{line}�
{frame}{line}�r�framerzPress Enter to Continuez!Not pausing for user confirmationN)r�logger�debugr+r�formatr�linesep�
SIDE_FRAMEr�
_can_interactr )r.�messager!r#r,r"rrrr&|s"
�
���


zFileDisplay.notificationNc	KsB|�||||�rt|fS|�||�|�t|��\}
}|
|dfS)aCDisplay a menu.

        .. todo:: This doesn't enable the help label/button (I wasn't sold on
           any interface I came up with for this). It would be a nice feature

        :param str message: title of menu
        :param choices: Menu lines, len must be > 0
        :type choices: list of tuples (tag, item) or
            list of descriptions (tags will be enumerated)
        :param default: default value to return (if one exists)
        :param str cli_flag: option used to set this value with the CLI
        :param bool force_interactive: True if it's safe to prompt the user
            because it won't cause any workflow regressions

        :returns: tuple of (`code`, `index`) where
            `code` - str display exit code
            `index` - int index of the user's selection

        :rtype: tuple

        �)�_return_default�OK�_print_menu�_get_valid_int_ans�len)r.r>�choices�ok_label�cancel_label�
help_label�default�cli_flagr,�
unused_kwargs�code�	selectionrrr�menu�s
zFileDisplay.menucKsH|�||||�rt|fStd|�d}t|�}|dvr@tdfSt|fS)aAccept input from the user.

        :param str message: message to display to the user
        :param default: default value to return (if one exists)
        :param str cli_flag: option used to set this value with the CLI
        :param bool force_interactive: True if it's safe to prompt the user
            because it won't cause any workflow regressions

        :returns: tuple of (`code`, `input`) where
            `code` - str display exit code
            `input` - str of the user's input
        :rtype: tuple

        z%s (Enter 'c' to cancel):� )�c�Cz-1)r@rArr �CANCEL)r.r>rIrJr,rK�ansrrr�input�szFileDisplay.input�Yes�Noc	Ks�|�||||�r|St|�}|j�djtjttj|d��|j��t	djt
|�t
|�d��}|�|d���s�|�|d�
��r�dS|�|d���s�|�|d�
��rFdSqFdS)	a�Query the user with a yes/no question.

        Yes and No label must begin with different letters, and must contain at
        least one letter each.

        :param str message: question for the user
        :param str yes_label: Label of the "Yes" parameter
        :param str no_label: Label of the "No" parameter
        :param default: default value to return (if one exists)
        :param str cli_flag: option used to set this value with the CLI
        :param bool force_interactive: True if it's safe to prompt the user
            because it won't cause any workflow regressions

        :returns: True for "Yes", False for "No"
        :rtype: bool

        z{0}{frame}{msg}{0}{frame})r7rz{yes}/{no}: )ZyesZnorTFN)r@rr+rr:rr;r<rr �_parens_around_char�
startswith�lower�upper)	r.r>�	yes_label�no_labelrIrJr,rKrSrrr�yesno�s&
�
���zFileDisplay.yesnocKs�|�||||�rt|fS|�||�|jddd�\}}|tkr�|��shd�dd�tdt|�d�D��}t|�}	|�	|	|�}
|
r�||
fS|j
�dtj
�|j
��q|gfSqd	S)
aCDisplay a checklist.

        :param str message: Message to display to user
        :param list tags: `str` tags to select, len(tags) > 0
        :param default: default value to return (if one exists)
        :param str cli_flag: option used to set this value with the CLI
        :param bool force_interactive: True if it's safe to prompt the user
            because it won't cause any workflow regressions

        :returns: tuple of (`code`, `tags`) where
            `code` - str display exit code
            `tags` - list of selected tags
        :rtype: tuple

        zrSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shownT)r,rOcss|]}t|�VqdS�N��str)�.0�xrrr�	<genexpr>"�z(FileDisplay.checklist.<locals>.<genexpr>r?z!** Error - Invalid selection **%sN)r@rArBrT�stripr�rangerD�separate_list_input�_scrub_checklist_inputr+rrr;r)r.r>�tagsrIrJr,rKrLrS�indicesZ
selected_tagsrrr�	checklists$�
"�zFileDisplay.checklistcCsN|�|�rdS|dur<d�|�}|r2|d�|�7}t�|��t�d||�dS)a�Should we return the default instead of prompting the user?

        :param str prompt: prompt for the user
        :param default: default answer to prompt
        :param str cli_flag: command line option for setting an answer
            to this question
        :param bool force_interactive: if interactivity is forced by the
            IDisplay call

        :returns: True if we should return the default without prompting
        :rtype: bool

        FNz-Unable to get an answer for the question:
{0}zA
You can provide an answer on the command line with the {0} flag.z-Falling back to default %s for the prompt:
%sT)r=r:r�Errorr8r9)r.rrIrJr,rrrrr@-s 

��
�zFileDisplay._return_defaultcCs@|js|stj��r"|j��r"dS|js<t�dtj	�d|_dS)z�Can we safely interact with the user?

        :param bool force_interactive: if interactivity is forced by the
            IDisplay call

        :returns: True if the display can interact with the user
        :rtype: bool

        Tz�Skipped user interaction because Certbot doesn't appear to be running in a terminal. You should probably include --non-interactive or %s on the command line.F)
r,r�stdin�isattyr+r-r8ZwarningrZFORCE_INTERACTIVE_FLAG)r.r,rrrr=Js

���zFileDisplay._can_interactcKs<t��� |�||||�Wd�S1s.0YdS)a
Display a directory selection screen.

        :param str message: prompt to give the user
        :param default: default value to return (if one exists)
        :param str cli_flag: option used to set this value with the CLI
        :param bool force_interactive: True if it's safe to prompt the user
            because it won't cause any workflow regressions

        :returns: tuple of the form (`code`, `string`) where
            `code` - display exit code
            `string` - input entered by the user

        N)rZ	CompleterrT)r.r>rIrJr,rKrrr�directory_select`s
zFileDisplay.directory_selectcsnzdd�|D�}Wnty(gYS0tt|��}|D] }|dksR|t��kr:gSq:�fdd�|D�S)z�Validate input and transform indices to appropriate tags.

        :param list indices: input
        :param list tags: Original tags of the checklist

        :returns: valid tags the user selected
        :rtype: :class:`list` of :class:`str`

        cSsg|]}t|��qSr)�int�ra�indexrrr�
<listcomp>~rdz6FileDisplay._scrub_checklist_input.<locals>.<listcomp>r?csg|]}�|d�qS)r?rrq�rirrrs�rd)�
ValueError�list�setrD)r.rjrirrrrtrrhrs

z"FileDisplay._scrub_checklist_inputcCs�|r t|dt�r dd�|D�}|j�djtj|d��|j�ttj�t|d�D]4\}}dj||d�}|j�t	|��|j�tj�qT|j�ttj�|j�
�d	S)
z�Print a menu on the screen.

        :param str message: title of menu
        :param choices: Menu lines
        :type choices: list of tuples (tag, item) or
            list of descriptions (tags will be enumerated)

        rcSs g|]}d|d|df�qS)z%s - %srr?r)rarPrrrrs�rdz+FileDisplay._print_menu.<locals>.<listcomp>z{new}{msg}{new})�newrr?z
{num}: {desc})Znum�descN)�
isinstance�tupler+rr:rr;r<�	enumeraterr)r.r>rE�iryrrrrrB�s
�zFileDisplay._print_menucCs�d}|dkrdj|d�}nd}|dkr�t|�}|�d�sB|�d�rJtdfSz$t|�}|dksd||krld}t�Wqty�|j�d�tj	��|j�
�Yq0qt|fS)	a5Get a numerical selection.

        :param int max: The maximum entry (len of choices), must be positive

        :returns: tuple of the form (`code`, `selection`) where
            `code` - str display exit code ('ok' or cancel')
            `selection` - int user's selection
        :rtype: tuple

        ���r?zMSelect the appropriate number [1-{max_}] then [enter] (press 'c' to cancel): )�max_z@Press 1 [enter] to confirm the selection (press 'c' to cancel): rPrQz{0}** Invalid input **{0})r:r rXrRrprur+rrr;rrA)r.rrMZ	input_msgrSrrrrC�s*�
�zFileDisplay._get_valid_int_ans)TTFT)NNNNNF)NNF)rUrVNNF)NNF)NNF)�__name__�
__module__�__qualname__�__doc__r*r&rNrTr]rkr@r=rorhrBrC�
__classcell__rrr/rr(qs6�
"�
!�
�
*�
)�
r(cCs4d�|�}|r|d�|�7}|dus0|s0J|��dS)aNVerify that provided arguments is a valid IDisplay call.

    :param str prompt: prompt for the user
    :param default: default answer to prompt
    :param str cli_flag: command line option for setting an answer
        to this question
    :param bool force_interactive: if interactivity is forced by the
        IDisplay call

    z*Invalid IDisplay call for this prompt:
{0}z7
You can set an answer to this prompt with the {0} flagN�r:)rrIrJr,rrrr�assert_valid_call�s
�r�csfeZdZdZ�fdd�Zddd�Zdd	d
�Zddd
�Zddd�Zddd�Z	ddd�Z
ddd�Z�ZS)�NoninteractiveDisplayzEAn iDisplay implementation that never asks for interactive user inputcstt|���||_dSr^)r)r�r*r+)r.r+Zunused_argsrKr/rrr*�szNoninteractiveDisplay.__init__r3cCs<d}||7}|r|d|7}|r.|d�|�7}t�|��dS)zBError out in case of an attempt to interact in noninteractive modez<Missing command line flag or config entry for this setting:
r
z&

(You can set this with the {0} flag)N)r:rZMissingCommandlineFlag)r.r>rJZextrarrrr�_interaction_fail�sz'NoninteractiveDisplay._interaction_failFTcKsX|rt|�}t�d|�|j�|r&dndd|r4dndjtjt|d��|j�	�dS)aeDisplays a notification without waiting for user acceptance.

        :param str message: Message to display to stdout
        :param bool pause: The NoninteractiveDisplay waits for no keyboard
        :param bool wrap: Whether or not the application should wrap text
        :param bool decorate: Whether to apply a decorated frame to the message

        r1r2r3r4r5r6N)
rr8r9r+rr:rr;r<r)r.r>r!r#r"rKrrrr&�s	
�
���z"NoninteractiveDisplay.notificationNc	Ks&|dur|�||dt|��t|fS)a_Avoid displaying a menu.

        :param str message: title of menu
        :param choices: Menu lines, len must be > 0
        :type choices: list of tuples (tag, item) or
            list of descriptions (tags will be enumerated)
        :param int default: the default choice
        :param dict kwargs: absorbs various irrelevant labelling arguments

        :returns: tuple of (`code`, `index`) where
            `code` - str display exit code
            `index` - int index of the user's selection
        :rtype: tuple
        :raises errors.MissingCommandlineFlag: if there was no default

        Nz	Choices: )r��reprrA)	r.r>rErFrGrHrIrJrKrrrrNszNoninteractiveDisplay.menucKs|dur|�||�t|fS)aKAccept input from the user.

        :param str message: message to display to the user

        :returns: tuple of (`code`, `input`) where
            `code` - str display exit code
            `input` - str of the user's input
        :rtype: tuple
        :raises errors.MissingCommandlineFlag: if there was no default

        N)r�rA�r.r>rIrJrKrrrrT szNoninteractiveDisplay.inputcKs|dur|�||�|S)a+Decide Yes or No, without asking anybody

        :param str message: question for the user
        :param dict kwargs: absorbs yes_label, no_label

        :raises errors.MissingCommandlineFlag: if there was no default
        :returns: True for "Yes", False for "No"
        :rtype: bool

        N)r�)r.r>r[r\rIrJrKrrrr]0szNoninteractiveDisplay.yesnocKs$|dur|�||d�|��t|fS)ajDisplay a checklist.

        :param str message: Message to display to user
        :param list tags: `str` tags to select, len(tags) > 0
        :param dict kwargs: absorbs default_status arg

        :returns: tuple of (`code`, `tags`) where
            `code` - str display exit code
            `tags` - list of selected tags
        :rtype: tuple

        Nz? )r�rrA)r.r>rirIrJrKrrrrk@szNoninteractiveDisplay.checklistcKs|�|||�S)a�Simulate prompting the user for a directory.

        This function returns default if it is not ``None``, otherwise,
        an exception is raised explaining the problem. If cli_flag is
        not ``None``, the error message will include the flag that can
        be used to set this value with the CLI.

        :param str message: prompt to give the user
        :param default: default value to return (if one exists)
        :param str cli_flag: option used to set this value with the CLI

        :returns: tuple of the form (`code`, `string`) where
            `code` - int display exit code
            `string` - input entered by the user

        )rTr�rrrroRsz&NoninteractiveDisplay.directory_select)r3)FTT)NNNNN)NN)NNNN)NN)NN)
r�r�r�r�r*r�r&rNrTr]rkror�rrr/rr��s"


�

�
�
�r�cCs|�dd�}dd�|��D�S)z�Separate a comma or space separated list.

    :param str input_: input from the user

    :returns: strings
    :rtype: list

    �,rOcSsg|]}t|��qSrr_)ra�stringrrrrssrdz'separate_list_input.<locals>.<listcomp>)�replace�split)Zinput_Z	no_commasrrrrggs	rgcCsdj|d|dd�d�S)znPlace parens around first character of label.

    :param str label: Must contain at least one character

    z({first}){rest}rr?N)�first�restr�)ZlabelrrrrWvsrWcCsJ|sdSt|�}|dkr |dS|dkr2d�|�Sd�|d|d�SdS)aMSummarizes a list of domains in the format of:
        example.com.com and N more domains
    or if there is are only two domains:
        example.com and www.example.com
    or if there is only one domain:
        example.com

    :param list domains: `str` list of domains
    :returns: the domain list summary
    :rtype: str
    r3r?r�z and z{0} and {1} more domainsN)rDrr:)Zdomains�lrrr�summarize_domain_lists

r�)Nr))r�ZloggingrrZzope.interfacer$Zzope.componentZacme.magic_typingrZcertbotrrZcertbot._internalrZcertbot._internal.displayrZcertbot.compatrrZ	getLoggerr�r8ZWIDTHrArRZHELPZESCr<rr r'Z	interfaceZimplementerr%�objectr(r�r�rgrWr�rrrr�<module>sB

^	

Youez - 2016 - github.com/yon3zu
LinuXploit