AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/certbot/_internal/display/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/certbot/_internal/display/__pycache__/obj.cpython-310.pyc
o

6��aR�@s dZddlZddlZddlmZddlmZddlZddlZddl	m
Z
ddl	mZddlm
Z
ddlmZdd	lmZdd
lmZe�e�ZdZ	dZ	d
Z	Gdd�d�Ze�Zej�ej�Gdd�d��Zej�ej�Gdd�d��Zdeeeffdd�Z deeefddfdd�Z!dS)zFThis modules define the actual display implementations used in Certbot�N)�Optional)�Union)�errors)�
interfaces)�	constants)�	completer)�util)�os�ok�cancelzO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -c@seZdZdd�ZdS)�_DisplayServicecCs
d|_dS�N��display)�self�r�?/usr/lib/python3/dist-packages/certbot/_internal/display/obj.py�__init__&s
z_DisplayService.__init__N)�__name__�
__module__�__qualname__rrrrrr%srcs�eZdZdZ�fdd�Z			ddd�Z			d d	d
�Z		d!dd�Z		d"dd�Z		d!dd�Z	dd�Z
dd�Z		d!dd�Zdd�Z
dd�Zdd�Z�ZS)#�FileDisplayzFile-based display.cs t���||_||_d|_dS)NF)�superr�outfile�force_interactive�skipped_interaction)rrr��	__class__rrr4s

zFileDisplay.__init__TFcCs�|rt�|�}t�d|�|j�|rdndd|rdndjtjt	|d��|j�
�|r@|�|�r9t�d�d	St�d�d	Sd	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}��line�frame�msgzPress Enter to Continuez!Not pausing for user confirmationN)
r�
wrap_lines�logger�debugr�write�formatr	�linesep�
SIDE_FRAME�flush�
_can_interact�input_with_timeout)r�message�pause�wrapr�decoraterrr�notification:s$

�
�
��

�zFileDisplay.notificationNc	KsB|�||||�rt|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)rr1�choices�ok_label�cancel_label�
help_label�default�cli_flagr�
unused_kwargs�code�	selectionrrr�menu\s
zFileDisplay.menucKsL|�||||�rt|fSt�d|�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)r7r8rr'r0�CANCEL)rr1r@rArrB�ansrrr�input}s
zFileDisplay.input�Yes�Noc	Ks�|�||||�r
|St�|�}|j�djtjttj|d��|j�	�	t�
djt�|�t�|�d��}|�|d�
��sG|�|d���rIdS|�|d�
��s[|�|d���r]dSq%)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})r%r&Tz{yes}/{no}: )�yes�norF)r7rr'rr*r+r	r,r-r.r0�parens_around_char�
startswith�lower�upper)	rr1�	yes_label�no_labelr@rArrBrJrrr�yesno�s*

�
����zFileDisplay.yesnocKs�|�||||�rt|fS	|�||�|jddd�\}}|tkrU|��s5d�dd�tdt|�d�D��}t�	|�}	|�
|	|�}
|
rF||
fS|j�dt
j�|j��n|gfSq
)	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

        TzrSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown)rrFcss�|]}t|�VqdSr
)�str)�.0�xrrr�	<genexpr>�s�z(FileDisplay.checklist.<locals>.<genexpr>r6z!** Error - Invalid selection **%s)r7r8r9rK�strip�join�ranger;r�separate_list_input�_scrub_checklist_inputrr*r	r,r.)rr1�tagsr@rArrBrCrJ�indices�
selected_tagsrrr�	checklist�s(
�"
��zFileDisplay.checklistcCsN|�|�rdS|durd�|�}|r|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

        :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�Errorr(r))r�promptr@rArr&rrrr7�s

�
�zFileDisplay._return_defaultcCs@|js|stj��r|j��rdS|jst�dtj	�d|_dS)z�Can we safely interact with the user?

        :param bool force_interactive: if interactivity is forced

        :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�sys�stdin�isattyrrr(�warningr�FORCE_INTERACTIVE_FLAG)rrrrrr/s
	���zFileDisplay._can_interactcKs<t���|�||||�Wd�S1swYdS)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)r�	CompleterrK)rr1r@rArrBrrr�directory_selects
$�zFileDisplay.directory_selectcsnz	dd�|D�}WntygYSwtt|��}|D]}|dks)|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�rX�indexrrr�
<listcomp>;sz6FileDisplay._scrub_checklist_input.<locals>.<listcomp>r6csg|]}�|d�qS)r6rrn�r`rrrpGs)�
ValueError�list�setr;)rrar`rorrqrr_/s��z"FileDisplay._scrub_checklist_inputcCs�|rt|dt�rdd�|D�}|j�djtj|d��|j�ttj�t|d�D]\}}dj||d�}|j�t	�
|��|j�tj�q*|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 - %srr6r)rXrGrrrrpTs z+FileDisplay._print_menu.<locals>.<listcomp>z{new}{msg}{new})�newr&r6z
{num}: {desc})�num�descN)�
isinstance�tuplerr*r+r	r,r-�	enumeraterr'r.)rr1r<�irwr&rrrr9Is
�zFileDisplay._print_menucCs�d}|dkr
dj|d�}nd}|dkrUt�|�}|�d�s"|�d�r&tdfSzt|�}|dks3||kr7d}t�WntyP|j�d�t	j
��|j��Ynw|dkst|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

        ���r6zMSelect the appropriate number [1-{max_}] then [enter] (press 'c' to cancel): )�max_z@Press 1 [enter] to confirm the selection (press 'c' to cancel): rGrHz{0}** Invalid input **{0})
r+rr0rQrIrmrrrr*r	r,r.r8)rr}rD�	input_msgrJrrrr:fs0�
�
���zFileDisplay._get_valid_int_ans)TTFT)NNNNNF)NNF)rLrMNNF)rrr�__doc__rr5rErKrVrcr7r/rlr_r9r:�
__classcell__rrrrr/s8
�"
�!
�
�*
�)
�rcsveZdZdZ�fdd�Zddd�Zdd	d
�Z		ddd
�Zddd�Z		ddd�Z			ddd�Z
		ddd�Z�ZS)�NoninteractiveDisplayzKA display utility implementation that never asks for interactive user inputcst���||_dSr
)rrr)rr�unused_argsrBrrrr�s

zNoninteractiveDisplay.__init__r cCs8d}||7}|r|d|7}|r|d�|�7}t�|��)zBError out in case of an attempt to interact in noninteractive modez<Missing command line flag or config entry for this setting:
�
z&

(You can set this with the {0} flag))r+r�MissingCommandlineFlag)rr1rA�extrar&rrr�_interaction_fail�s
z'NoninteractiveDisplay._interaction_failFTcKsZ|rt�|�}t�d|�|j�|rdndd|rdndjtjt	|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

        rrr r!r"r#N)rr'r(r)rr*r+r	r,r-r.)rr1r2r3r4rBrrrr5�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��reprr8)	rr1r<r=r>r?r@rArBrrrrE�szNoninteractiveDisplay.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�r8�rr1r@rArBrrrrK�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�)rr1rTrUr@rArBrrrrV�szNoninteractiveDisplay.yesnocKs(|dur|�||d�|�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�r\r8)rr1r`r@rArBrrrrc�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

        )rKr�rrrrl�sz&NoninteractiveDisplay.directory_select)r )FTT)NNNNN)NN)NNNN)
rrrrrr�r5rErKrVrcrlr�rrrrr��s$



�

�
��r��returncCstjstd��tjS)z�Get the display utility.

    :return: the display utility
    :rtype: Union[FileDisplay, NoninteractiveDisplay]
    :raise: ValueError if the display utility is not configured yet.

    zlThis function was called too early in Certbot's execution as the display utility hasn't been configured yet.)�_SERVICErrrrrrr�get_displaysr�rcCstj�|tj�|t_dS)zqSet the display service.

    :param Union[FileDisplay, NoninteractiveDisplay] display: the display service

    N)�zope�	component�provideUtilityr�IDisplayr�rrrrr�set_display"s
r�)"r�loggingrf�typingrr�zope.componentr��zope.interface�certbotrr�certbot._internalr�certbot._internal.displayrr�certbot.compatr	�	getLoggerrr(r8rIr-rr��	interface�implementerr�rr�r�r�rrrr�<module>s>
	_

Anon7 - 2022
AnonSec Team