ok

Mini Shell

Direktori : /lib/python3.6/site-packages/certbot/display/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/certbot/display/__pycache__/ops.cpython-36.pyc

3

گas4�	@s�dZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZdd
lmZddlmZdd
lmZddlmZdd
lmZeje�ZdAeeed�dd�Zeeje	ejd�dd�ZdBeee	eeed�dd�Z dCe	ej!e	eeed�dd�Z"eeeed�dd �Z#eeeed!�d"d#�Z$dDeee	eeeeefd$�d%d&�Z%dEeeed(�d)d*�Z&e
edd�d+d,�Z'e
edd-�d.d/�Z(edd0�d1d2�Z)ee*eedd3�d4d5�Z+e
eed�d6d7�Z,dFed8eeeffeegefee	eeeeefd9�d:d;�Z-eegefeeeeefd<�d=d>�Z.eegefeeeeefd<�d?d@�Z/dS)Gz+Contains UI methods for LE user operations.�N)�indent)�Any)�Callable)�Iterable)�List)�Optional)�Sequence)�Tuple)�errors)�
interfaces)�util)�account)�osFT)�invalid�optional�returncCs�d}d}d}|r(|r"||7}d}q,d}nd}x�y"tj|r@||n|dd�\}}Wn$tjk
rtd}tj|��YnX|tjkr�|r�tjd��tjd	��tj|�r�|S|r�||}d}t|�}q.Wd
S)aJPrompt for valid email address.

    :param bool invalid: True if an invalid address was provided by the user
    :param bool optional: True if the user can use
        --register-unsafely-without-email to avoid providing an e-mail

    :returns: e-mail address
    :rtype: str

    :raises errors.Error: if the user cancels

    z-There seem to be problems with that address. zCEnter email address (used for urgent renewal and security notices)
a

If you really want to skip this, you can run the client with --register-unsafely-without-email but you will then be unable to receive notice about impending expiration or revocation of your certificates or problems with your Certbot installation that will lead to failure to renew.

FT)�force_interactivezoYou should register before running non-interactively, or provide --agree-tos and --email <email_address> flags.zHAn e-mail address or --register-unsafely-without-email must be provided.z#An e-mail address must be provided.N)	�display_util�
input_textr
ZMissingCommandlineFlag�OK�ErrorrZ
safe_email�bool)rrZinvalid_prefix�msgZunsafe_suggestionZsuggest_unsafe�codeZemail�r�/usr/lib/python3.6/ops.py�	get_emails6



r)�accountsrcCs8dd�|D�}tjd|dd�\}}|tjkr4||SdS)zChoose an account.

    :param list accounts: Containing at least one
        :class:`~certbot._internal.account.Account`

    cSsg|]
}|j�qSr)Zslug)�.0Zaccrrr�
<listcomp>Usz"choose_account.<locals>.<listcomp>zPlease choose an accountT)rN)rZmenur)rZlabelsr�indexrrr�choose_accountMs

r!)�values�questionrcCs2tj|r|nd|dd�\}}|tjkr.|r.|SgS)aDisplay screen to let user pick one or multiple values from the provided
    list.

    :param list values: Values to select from
    :param str question: Question to ask to user while choosing values

    :returns: List of selected values
    :rtype: list
    �T)�tagsr)r�	checklistr)r"r#r�itemsrrr�
choose_values]s

r()�	installerr#rcCsZ|dkrtjd�t�St|j��}t|�}|s6t�St||�\}}|tjkrV|rV|SgS)aQDisplay screen to select domains to validate.

    :param installer: An installer object
    :type installer: :class:`certbot.interfaces.Installer`

    :param `str` question: Overriding default question to ask the user if asked
        to choose from domain names.

    :returns: List of selected names
    :rtype: `list` of `str`

    Nz$No installer, picking names manually)	�logger�debug�_choose_names_manually�listZ
get_all_names�get_valid_domains�
_filter_namesrr)r)r#�domains�namesrrrr�choose_namesns
r2)r0rcCsDg}x:|D]2}y|jtj|��Wq
tjk
r:w
Yq
Xq
W|S)z�Helper method for choose_names that implements basic checks
     on domain names

    :param list domains: Domain names to validate
    :return: List of valid domains
    :rtype: list
    )�appendr�enforce_domain_sanityr
�ConfigurationError)r0Z
valid_domains�domainrrrr.�s
r.)�FQDNsrcCst|dd�d�S)z�Sort FQDNs by SLD (and if many, by their subdomains)

    :param list FQDNs: list of domain names

    :returns: Sorted list of domain names
    :rtype: list
    cSs|jd�ddd�dd�S)N�.����)�split)Zfqdnrrr�<lambda>�sz_sort_names.<locals>.<lambda>)�key)�sorted)r7rrr�_sort_names�sr?)r1�override_questionrcCs>t|�}|r|}nd}tj||ddd�\}}|dd�|D�fS)aDetermine which names the user would like to select from a list.

    :param list names: domain names

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

    z1Which names would you like to activate HTTPS for?z	--domainsT)r%�cli_flagrcSsg|]}t|��qSr)�str)r�srrrr�sz!_filter_names.<locals>.<listcomp>)r?rr&)r1r@Zsorted_namesr#rrrrr/�s
r/r$)�
prompt_prefixrcCs0tj|dddd�\}}|tjk�r,i}d}ytj|�}Wn$tk
r^g}djtj�}YnXxXt	|�D]L\}}yt
j|�||<Wqjtj
k
r�}zt|�||<WYdd}~XqjXqjW|�rdjtj�}x(|j�D]\}	}
|d	jtj|	|
�}q�W|d
jtj�}|�r(tj|dd�}|�r,t�Sn|SgS)z�Manually input names for those without an installer.

    :param str prompt_prefix: string to prepend to prompt for domains

    :returns: list of provided names
    :rtype: `list` of `str`

    zaPlease enter the domain name(s) you would like on your certificate (comma and/or space separated)z	--domainsT)rArr$ziInternationalized domain names are not presently supported.{0}{0}Would you like to re-enter the names?{0}Nz<One or more of the entered domain names was not valid:{0}{0}z{1}: {2}{0}z+{0}Would you like to re-enter the names?{0})r)rrr�internal_display_utilZseparate_list_input�UnicodeEncodeError�formatr�linesep�	enumeraterr4r
r5rBr'Zyesnor,)rDrZinput_Zinvalid_domainsZ
retry_messageZdomain_list�ir6�eZinvalid_domain�errZretryrrrr,�sB	"
r,cCstjdjt|���dS)zsDisplay a box confirming the installation of HTTPS.

    :param list domains: domain names which were enabled

    z;Congratulations! You have successfully enabled HTTPS on {0}N)r�notifyrG�_gen_https_names)r0rrr�success_installation�srO)�unused_domainsrcCstjd�dS)z�Display a box confirming the renewal of an existing certificate.

    :param list domains: domain names which were renewed

    zdYour existing certificate has been successfully renewed, and the new certificate has been installed.N)rrM)rPrrr�success_renewalsrQ)�	cert_pathrcCstjdj|��dS)z�Display a message confirming a certificate has been revoked.

    :param list cert_path: path to certificate which was revoked.

    zWCongratulations! You have successfully revoked the certificate that was located at {0}.N)rrMrG)rRrrr�success_revocation
srS)�command_name�
returncode�stdout�stderrrcCsb|j�|j�}}|dkr(tjd||�|rFtj|�dt|d����|r^tjd|t|d��dS)aqDisplay a message describing the success or failure of an executed process (e.g. hook).

    :param str command_name: Human-readable description of the executed command
    :param int returncode: The exit code of the executed command
    :param str stdout: The stdout output of the executed command
    :param str stderr: The stderr output of the executed command

    rz%s reported error code %dz ran with output:
� z%s ran with error output:
%sN)�stripr*ZwarningrrMr)rTrUrVrWZout_sZerr_srrr�report_executed_commands	rZcCslt|�dkrdj|d�St|�dkr2dj|d�St|�dkrhdjdjd	d
�|dd�D��d|d�Sd
S)z�Returns a string of the https domains.

    Domains are formatted nicely with ``https://`` prepended to each.

    :param list domains: Each domain is a 'str'

    r9zhttps://{0}r�z%https://{dom[0]} and https://{dom[1]})�domz	{0}{1}{2}z, css|]}d|VqdS)z
https://%sNr)rr\rrr�	<genexpr>9sz#_gen_https_names.<locals>.<genexpr>Nz, and https://r$r:r:)�lenrG�join)r0rrrrN+s
rN.)�method�	validator�message�default�kwargsrcKs�|dk	rLy||�Wn6tjk
rJtjd||dd�tdj|���YnXx�||fd|i|��\}}|tjkr�y||�||fStjk
r�}z*tjd||dd�tjt	|�dd�WYdd}~Xq�XqN||fSqNWdS)	Nz>Encountered invalid default value "%s" when prompting for "%s"T)�exc_infozInvalid default "{0}"rcz/Validator rejected "%s" when prompting for "%s"F)�pause)
r
rr*r+�AssertionErrorrGrrZnotificationrB)r`rarbrcrdr�raw�errorrrr�_get_validated@s,
&rj)ra�argsrdrcOsttj|f|�|�S)aLike `~certbot.display.util.input_text`, but with validation.

    :param callable validator: A method which will be called on the
        supplied input. If the method raises an `errors.Error`, its
        text will be displayed and the user will be re-prompted.
    :param list `*args`: Arguments to be passed to `~certbot.display.util.input_text`.
    :param dict `**kwargs`: Arguments to be passed to `~certbot.display.util.input_text`.
    :return: as `~certbot.display.util.input_text`
    :rtype: tuple
    )rjrr)rarkrdrrr�validated_input]srlcOsttj|f|�|�S)a"Like `~certbot.display.util.directory_select`, but with validation.

    :param callable validator: A method which will be called on the
        supplied input. If the method raises an `errors.Error`, its
        text will be displayed and the user will be re-prompted.
    :param list `*args`: Arguments to be passed to `~certbot.display.util.directory_select`.
    :param dict `**kwargs`: Arguments to be passed to
        `~certbot.display.util.directory_select`.
    :return: as `~certbot.display.util.directory_select`
    :rtype: tuple
    )rjrZdirectory_select)rarkrdrrr�validated_directoryls
rm)FT)N)N)N)r$)N)0�__doc__Zlogging�textwraprZtypingrrrrrrr	Zcertbotr
rrZcertbot._internalr
Zcertbot._internal.displayrEZcertbot.compatrZcertbot.displayrZ	getLogger�__name__r*rrBrZAccountr!r(Z	Installerr2r.r?r/r,rOrQrS�intrZrNrjrlrmrrrr�<module>sF
6 "(6@

Zerion Mini Shell 1.0