Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : fdshops ( 1003)
PHP Version : 8.2.21
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/certbot/display/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/certbot/display/util.pyo
�
���_c@s�dZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZddlm
Z
ddlmZddlmZdd	lmZeje�Zd
ZdZdZd
ZdZdddZd�Zedd�Zd�Zej j!ej"�de#fd��Y�Z$d�Z%ej j!ej"�de#fd��Y�Z&d�Z'd�Z(d�Z)dS(s$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`.

i����N(tList(terrors(t
interfaces(t	constants(t	completer(tmisc(tosiHtoktcancelthelptescs- i't-c	CsU|j�}g}x3|D]+}|jtj|ddtdt��qWdj|�S(s�Format lines nicely to 80 chars.

    :param str msg: Original message

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

    iPtbreak_long_wordstbreak_on_hyphenss
(t
splitlinestappendttextwraptfilltFalsetjoin(tmsgtlinestfixed_ltline((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyt_wrap_lines1s	
g��@cCsT|r&tjj|�tjj�ntj||�}|sGt�n|jd�S(sGet 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

    s
(tsyststdouttwritetflushRtreadline_with_timeouttEOFErrortrstrip(tpromptttimeoutR((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytinput_with_timeoutGs	cCs2tjjtj�j|dtdtdt�dS(sMDisplay a basic status message.

    :param str msg: message to display

    tpausetdecoratetwrapN(tzopet	componentt
getUtilityRtIDisplaytnotificationR(R((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytnotifyestFileDisplaycBs�eZdZd�Zeeeed�Zddddded�Zdded�Z	dddded�Z
dded�Zd	�Zd
�Z
dded�Zd�Zd
�Zd�ZRS(sFile-based display.cCs2tt|�j�||_||_t|_dS(N(tsuperR,t__init__toutfiletforce_interactiveRtskipped_interaction(tselfR/R0((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR.vs		cCs�|rt|�}ntjd|�|jj|r:dndd|rMdndjdtjdtd|��|jj	�|r�|j
|�r�td	�q�tjd
�ndS(sDisplays 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

        sNotifying user: %ss{line}{frame}{line}ts{msg}{line}s
{frame}{line}RtframeRsPress Enter to Continues!Not pausing for user confirmationN(RtloggertdebugR/RtformatRtlinesept
SIDE_FRAMERt
_can_interactR"(R2tmessageR#R%R0R$((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR*|s	

c	Ks[|j||||�r"t|fS|j||�|jt|��\}
}|
|dfS(sCDisplay 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

        i(t_return_defaulttOKt_print_menut_get_valid_int_anstlen(R2R;tchoicestok_labeltcancel_labelt
help_labeltdefaulttcli_flagR0t
unused_kwargstcodet	selection((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytmenu�s

cKsb|j||||�r"t|fStd|�d}t|�}|dkrXtdfSt|fS(sAccept 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

        s%s (Enter 'c' to cancel):t tctCs-1(RLRM(R<R=RR"tCANCEL(R2R;RERFR0RGtans((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytinput�s

tYestNoc	Ks|j||||�r|St|�}|jjdjtjdttjd|��|jj�x�t	rt
djdt|�dt|���}|j|dj
��s�|j|dj��r�t	S|j|dj
��s�|j|dj��rgtSqgWdS(	s�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

        s{0}{frame}{msg}{0}{frame}R4Rs{yes}/{no}: tyestnoiN(R<RR/RR7RR8R9RtTrueR"t_parens_around_chart
startswithtlowertupperR(	R2R;t	yes_labeltno_labelRERFR0RGRO((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytyesno�s  
	cKs|j||||�r"t|fSx�tr�|j||�|jddt�\}}|tkr�|j�s�djd�tdt|�d�D��}nt	|�}	|j
|	|�}
|
r�||
fS|jjdt
j�|jj�q%|gfSq%WdS(sCDisplay 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

        srSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shownR0RKcss|]}t|�VqdS(N(tstr(t.0tx((s8/usr/lib/python2.7/site-packages/certbot/display/util.pys	<genexpr>"sis!** Error - Invalid selection **%sN(R<R=RUR>RPtstripRtrangeR@tseparate_list_inputt_scrub_checklist_inputR/RRR8R(R2R;ttagsRERFR0RGRHROtindicest
selected_tags((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyt	checklists"
	/
	cCss|j|�rtS|dkr\dj|�}|rJ|dj|�7}ntj|��ntjd||�tS(s�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

        s-Unable to get an answer for the question:
{0}sA
You can provide an answer on the command line with the {0} flag.s-Falling back to default %s for the prompt:
%sN(	R:RtNoneR7RtErrorR5R6RU(R2R RERFR0R((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR<-s

cCs]|js-|s-tjj�r1|jj�r1tS|jsYtjdt	j
�t|_ntS(s�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

        s�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.(R0RtstdintisattyR/RUR1R5twarningRtFORCE_INTERACTIVE_FLAGR(R2R0((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR:Js
	
c	Ks-tj��|j||||�SWdQXdS(s
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(Rt	CompleterRP(R2R;RERFR0RG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytdirectory_select`s
cCs�y#g|D]}t|�^q
}Wntk
r7gSXtt|��}x0|D](}|dksu|t|�krQgSqQWg|D]}||d^q�S(s�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`

        i(tintt
ValueErrortlisttsetR@(R2ReRdtindex((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRcrs#

cCs|rGt|dt�rGg|D]}d|d|df^q }n|jjdjdtjd|��|jjttj�x^t|d�D]M\}}djd|d	|�}|jjt	|��|jjtj�q�W|jjttj�|jj
�d
S(s�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)

        is%s - %sis{new}{msg}{new}tnewRs
{num}: {desc}tnumtdescN(t
isinstancettupleR/RR7RR8R9t	enumerateRR(R2R;RARLtiRwR((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR>�s
.	cCs�d}|dkr'djd|�}nd}x�|dkr�t|�}|jd�sf|jd�rptdfSy7t|�}|dks�||kr�d}t�nWq0tk
r�|jjdjtj	��|jj
�q0Xq0Wt|fS(	s5Get 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

        i����isMSelect the appropriate number [1-{max_}] then [enter] (press 'c' to cancel): tmax_s@Press 1 [enter] to confirm the selection (press 'c' to cancel): RLRMs{0}** Invalid input **{0}(R7R"RWRNRpRqR/RRR8RR=(R2R|RIt	input_msgRO((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR?�s&	


	N(t__name__t
__module__t__doc__R.RURR*RhRJRPR\RgR<R:RoRcR>R?(((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR,qs*	 	)(				cCs/dj|�}|r+|dj|�7}ndS(sNVerify 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

    s*Invalid IDisplay call for this prompt:
{0}s7
You can set an answer to this prompt with the {0} flagN(R7(R RERFR0R((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytassert_valid_call�s
	
tNoninteractiveDisplaycBs�eZdZd�Zdd�Zeeed�Zd
d
d
d
d
d�Z	d
d
d�Z
d
d
d
d
d�Zd
d
d�Zd
d
d	�Z
RS(sEAn iDisplay implementation that never asks for interactive user inputcOs tt|�j�||_dS(N(R-R�R.R/(R2R/tunused_argsRG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR.�sR3cCsVd}||7}|r'|d|7}n|rC|dj|�7}ntj|��dS(sBError out in case of an attempt to interact in noninteractive modes<Missing command line flag or config entry for this setting:
s
s&

(You can set this with the {0} flag)N(R7RtMissingCommandlineFlag(R2R;RFtextraR((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyt_interaction_fail�s
cKs�|rt|�}ntjd|�|jj|r:dndd|rMdndjdtjdtd|��|jj	�d	S(
seDisplays 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

        sNotifying user: %ss{line}{frame}{line}R3s{msg}{line}s
{frame}{line}RR4RN(
RR5R6R/RR7RR8R9R(R2R;R#R%R$RG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR*�s		c	Ks6|dkr,|j||dt|��nt|fS(s_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

        s	Choices: N(RhR�treprR=(	R2R;RARBRCRDRERFRG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRJs cKs)|dkr|j||�nt|fS(sKAccept 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(RhR�R=(R2R;RERFRG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRP scKs#|dkr|j||�n|S(s+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(RhR�(R2R;RZR[RERFRG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR\0scKs5|dkr+|j||dj|��nt|fS(sjDisplay 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

        s? N(RhR�RR=(R2R;RdRERFRG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRg@scKs|j|||�S(s�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

        (RP(R2R;RERFRG((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRoRsN(R~RR�R.R�RRUR*RhRJRPR\RgRo(((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyR��s	
cCs5|jdd�}g|j�D]}t|�^qS(s�Separate a comma or space separated list.

    :param str input_: input from the user

    :returns: strings
    :rtype: list

    t,RK(treplacetsplitR](tinput_t	no_commaststring((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRbgs	cCsdjd|dd|d�S(snPlace parens around first character of label.

    :param str label: Must contain at least one character

    s({first}){rest}tfirstitresti(R7(tlabel((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyRVvscCs_|s
dSt|�}|dkr*|dS|dkrCdj|�Sdj|d|d�SdS(sMSummarizes 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
    R3iiis and s{0} and {1} more domainsN(R@RR7(tdomainstl((s8/usr/lib/python2.7/site-packages/certbot/display/util.pytsummarize_domain_lists

(*R�tloggingRRtzope.interfaceR&tzope.componenttacme.magic_typingRtcertbotRRtcertbot._internalRtcertbot._internal.displayRtcertbot.compatRRt	getLoggerR~R5tWIDTHR=RNtHELPtESCR9RRhR"R+t	interfacetimplementerR)tobjectR,R�R�RbRVR�(((s8/usr/lib/python2.7/site-packages/certbot/display/util.pyt<module>s>		�]	�			

Spamworldpro Mini