certbot.display
¶
Certbot display utilities.
certbot.display.util
¶
Certbot display.
-
certbot.display.util.
OK
= 'ok'¶ Display exit code indicating user acceptance.
-
certbot.display.util.
CANCEL
= 'cancel'¶ Display exit code for a user canceling the display.
-
certbot.display.util.
HELP
= 'help'¶ Display exit code when for when the user requests more help.
-
certbot.display.util.
ESC
= 'esc'¶ Display exit code when the user hits Escape
-
certbot.display.util.
_wrap_lines
(msg)[source]¶ Format lines nicely to 80 chars.
Parameters: msg (str) – Original message Returns: Formatted message respecting newlines in message Return type: str
-
certbot.display.util.
input_with_timeout
(prompt=None, timeout=36000.0)[source]¶ Get 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.
Parameters: Returns: user response
Return type: :raises errors.Error if no answer is given before the timeout
-
class
certbot.display.util.
FileDisplay
(outfile, force_interactive)[source]¶ Bases:
object
File-based display.
-
notification
(message, pause=True, wrap=True, force_interactive=False)[source]¶ Displays a notification and waits for user acceptance.
Parameters:
Display 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
Parameters: - message (str) – title of menu
- choices (list of tuples (tag, item) or list of descriptions (tags will be enumerated)) – Menu lines, len must be > 0
- default – default value to return (if one exists)
- cli_flag (str) – option used to set this value with the CLI
- force_interactive (bool) – True if it’s safe to prompt the user because it won’t cause any workflow regressions
Returns: tuple of (
code
,index
) wherecode
- str display exit codeindex
- int index of the user’s selectionReturn type:
-
input
(message, default=None, cli_flag=None, force_interactive=False, **unused_kwargs)[source]¶ Accept input from the user.
Parameters: Returns: tuple of (
code
,input
) wherecode
- str display exit codeinput
- str of the user’s inputReturn type:
-
yesno
(message, yes_label='Yes', no_label='No', default=None, cli_flag=None, force_interactive=False, **unused_kwargs)[source]¶ 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.
Parameters: - message (str) – question for the user
- yes_label (str) – Label of the “Yes” parameter
- no_label (str) – Label of the “No” parameter
- default – default value to return (if one exists)
- cli_flag (str) – option used to set this value with the CLI
- force_interactive (bool) – True if it’s safe to prompt the user because it won’t cause any workflow regressions
Returns: True for “Yes”, False for “No”
Return type:
-
checklist
(message, tags, default_status=True, default=None, cli_flag=None, force_interactive=False, **unused_kwargs)[source]¶ Display a checklist.
Parameters: - message (str) – Message to display to user
- tags (list) –
str
tags to select, len(tags) > 0 - default_status (bool) – Not used for FileDisplay
- default – default value to return (if one exists)
- cli_flag (str) – option used to set this value with the CLI
- force_interactive (bool) – True if it’s safe to prompt the user because it won’t cause any workflow regressions
Returns: tuple of (
code
,tags
) wherecode
- str display exit codetags
- list of selected tagsReturn type:
-
_return_default
(prompt, default, cli_flag, force_interactive)[source]¶ Should we return the default instead of prompting the user?
Parameters: Returns: True if we should return the default without prompting
Return type:
-
_can_interact
(force_interactive)[source]¶ Can we safely interact with the user?
Parameters: force_interactive (bool) – if interactivity is forced by the IDisplay call Returns: True if the display can interact with the user Return type: bool
-
directory_select
(message, default=None, cli_flag=None, force_interactive=False, **unused_kwargs)[source]¶ Display a directory selection screen.
Parameters: Returns: tuple of the form (
code
,string
) wherecode
- display exit codestring
- input entered by the user
-
_scrub_checklist_input
(indices, tags)[source]¶ Validate input and transform indices to appropriate tags.
Parameters: - indices (list) – input
- tags (list) – Original tags of the checklist
Returns: valid tags the user selected
Return type: list
ofstr
Print a menu on the screen.
Parameters: - message (str) – title of menu
- choices (list of tuples (tag, item) or list of descriptions (tags will be enumerated)) – Menu lines
-
-
certbot.display.util.
assert_valid_call
(prompt, default, cli_flag, force_interactive)[source]¶ Verify that provided arguments is a valid IDisplay call.
Parameters:
-
class
certbot.display.util.
NoninteractiveDisplay
(outfile, *unused_args, **unused_kwargs)[source]¶ Bases:
object
An iDisplay implementation that never asks for interactive user input
-
_interaction_fail
(message, cli_flag, extra='')[source]¶ Error out in case of an attempt to interact in noninteractive mode
-
notification
(message, pause=False, wrap=True, **unused_kwargs)[source]¶ Displays a notification without waiting for user acceptance.
Parameters:
Avoid displaying a menu.
Parameters: Returns: tuple of (
code
,index
) wherecode
- str display exit codeindex
- int index of the user’s selectionReturn type: Raises: errors.MissingCommandlineFlag – if there was no default
-
input
(message, default=None, cli_flag=None, **unused_kwargs)[source]¶ Accept input from the user.
Parameters: message (str) – message to display to the user Returns: tuple of ( code
,input
) wherecode
- str display exit codeinput
- str of the user’s inputReturn type: tuple Raises: errors.MissingCommandlineFlag – if there was no default
-
yesno
(message, yes_label=None, no_label=None, default=None, cli_flag=None, **unused_kwargs)[source]¶ Decide Yes or No, without asking anybody
Parameters: Raises: errors.MissingCommandlineFlag – if there was no default
Returns: True for “Yes”, False for “No”
Return type:
-
checklist
(message, tags, default=None, cli_flag=None, **unused_kwargs)[source]¶ Display a checklist.
Parameters: Returns: tuple of (
code
,tags
) wherecode
- str display exit codetags
- list of selected tagsReturn type:
-
directory_select
(message, default=None, cli_flag=None, **unused_kwargs)[source]¶ 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 notNone
, the error message will include the flag that can be used to set this value with the CLI.Parameters: Returns: tuple of the form (
code
,string
) wherecode
- int display exit codestring
- input entered by the user
-
certbot.display.ops
¶
Contains UI methods for LE user operations.
-
certbot.display.ops.
get_email
(invalid=False, optional=True)[source]¶ Prompt for valid email address.
Parameters: Returns: e-mail address
Return type: Raises: errors.Error – if the user cancels
-
certbot.display.ops.
choose_account
(accounts)[source]¶ Choose an account.
Parameters: accounts (list) – Containing at least one Account
-
certbot.display.ops.
choose_names
(installer)[source]¶ Display screen to select domains to validate.
Parameters: installer ( certbot.interfaces.IInstaller
) – An installer objectReturns: List of selected names Return type: list
ofstr
-
certbot.display.ops.
get_valid_domains
(domains)[source]¶ - Helper method for choose_names that implements basic checks
- on domain names
Parameters: domains (list) – Domain names to validate Returns: List of valid domains Return type: list
-
certbot.display.ops.
_sort_names
(FQDNs)[source]¶ Sort FQDNs by SLD (and if many, by their subdomains)
Parameters: FQDNs (list) – list of domain names Returns: Sorted list of domain names Return type: list
-
certbot.display.ops.
_filter_names
(names)[source]¶ Determine which names the user would like to select from a list.
Parameters: names (list) – domain names Returns: tuple of the form ( code
,names
) wherecode
- str display exit codenames
- list of names selectedReturn type: tuple
-
certbot.display.ops.
_choose_names_manually
(prompt_prefix='')[source]¶ Manually input names for those without an installer.
Parameters: prompt_prefix (str) – string to prepend to prompt for domains Returns: list of provided names Return type: list
ofstr
-
certbot.display.ops.
success_installation
(domains)[source]¶ Display a box confirming the installation of HTTPS.
Parameters: domains (list) – domain names which were enabled
-
certbot.display.ops.
success_renewal
(domains)[source]¶ Display a box confirming the renewal of an existing certificate.
Parameters: domains (list) – domain names which were renewed
-
certbot.display.ops.
success_revocation
(cert_path)[source]¶ Display a box confirming a certificate has been revoked.
Parameters: cert_path (list) – path to certificate which was revoked.
-
certbot.display.ops.
_gen_ssl_lab_urls
(domains)[source]¶ Returns a list of urls.
Parameters: domains (list) – Each domain is a ‘str’
-
certbot.display.ops.
_gen_https_names
(domains)[source]¶ Returns a string of the https domains.
Domains are formatted nicely with https:// prepended to each.
Parameters: domains (list) – Each domain is a ‘str’
-
certbot.display.ops.
validated_input
(validator, *args, **kwargs)[source]¶ Like
input
, but with validation.Parameters: Returns: as
input
Return type:
-
certbot.display.ops.
validated_directory
(validator, *args, **kwargs)[source]¶ Like
directory_select
, but with validation.Parameters: - validator (callable) – A method which will be called on the
supplied input. If the method raises a
errors.Error
, its text will be displayed and the user will be re-prompted. - *args (list) – Arguments to be passed to
directory_select
. - **kwargs (dict) – Arguments to be passed to
directory_select
.
Returns: Return type: - validator (callable) – A method which will be called on the
supplied input. If the method raises a
certbot.display.enhancements
¶
Certbot Enhancement Display
-
certbot.display.enhancements.
ask
(enhancement)[source]¶ Display the enhancement to the user.
Parameters: enhancement (str) – One of the certbot.CONFIG.ENHANCEMENTS
enhancementsReturns: True if feature is desired, False otherwise Return type: bool Raises: errors.Error – if the enhancement provided is not supported