mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:41:53 +02:00
Make iDisplay.menu() calls non-interactive where possible
- And provide helpful errors where they're not
This commit is contained in:
@@ -78,11 +78,17 @@ def _vhost_menu(domain, vhosts):
|
|||||||
name_size=disp_name_size)
|
name_size=disp_name_size)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
code, tag = zope.component.getUtility(interfaces.IDisplay).menu(
|
code, tag = zope.component.getUtility(interfaces.IDisplay).menu(
|
||||||
"We were unable to find a vhost with a ServerName or Address of {0}.{1}"
|
"We were unable to find a vhost with a ServerName or Address of {0}.{1}"
|
||||||
"Which virtual host would you like to choose?".format(
|
"Which virtual host would you like to choose?".format(domain, os.linesep),
|
||||||
domain, os.linesep),
|
|
||||||
choices, help_label="More Info", ok_label="Select")
|
choices, help_label="More Info", ok_label="Select")
|
||||||
|
except errors.MissingCommandlineFlag, e:
|
||||||
|
msg = ("Failed to run Apache plugin non-interactively{1}{0}{1}"
|
||||||
|
"(The best solution is to add ServerName or ServerAlias entries to "
|
||||||
|
"the VirtualHost directives of your apache configuration files.)".format(e,
|
||||||
|
os.linesep))
|
||||||
|
raise errors.MissingCommandlineFlag, msg
|
||||||
|
|
||||||
return code, tag
|
return code, tag
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -280,7 +280,7 @@ def _handle_identical_cert_request(config, cert):
|
|||||||
"Cancel this operation and do nothing"]
|
"Cancel this operation and do nothing"]
|
||||||
|
|
||||||
display = zope.component.getUtility(interfaces.IDisplay)
|
display = zope.component.getUtility(interfaces.IDisplay)
|
||||||
response = display.menu(question, choices, "OK", "Cancel")
|
response = display.menu(question, choices, "OK", "Cancel", default=0)
|
||||||
if response[0] == "cancel" or response[1] == 2:
|
if response[0] == "cancel" or response[1] == 2:
|
||||||
# TODO: Add notification related to command-line options for
|
# TODO: Add notification related to command-line options for
|
||||||
# skipping the menu for this case.
|
# skipping the menu for this case.
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def redirect_by_default():
|
|||||||
|
|
||||||
code, selection = util(interfaces.IDisplay).menu(
|
code, selection = util(interfaces.IDisplay).menu(
|
||||||
"Please choose whether HTTPS access is required or optional.",
|
"Please choose whether HTTPS access is required or optional.",
|
||||||
choices)
|
choices, default=0, cli_flag="--redirect / --no-redirect")
|
||||||
|
|
||||||
if code != display_util.OK:
|
if code != display_util.OK:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -31,8 +31,16 @@ def choose_plugin(prepared, question):
|
|||||||
for plugin_ep in prepared]
|
for plugin_ep in prepared]
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
code, index = util(interfaces.IDisplay).menu(
|
disp = util(interfaces.IDisplay)
|
||||||
question, opts, help_label="More Info")
|
try:
|
||||||
|
code, index = disp.menu(question, opts, help_label="More Info")
|
||||||
|
except errors.MissingCommandlineFlag:
|
||||||
|
# use a custom message for this case
|
||||||
|
raise errors.MissingCommandlineFlag, ("Missing command line flags. For non-interactive "
|
||||||
|
"execution, you will need to specify a plugin on the command line. Run with "
|
||||||
|
"'--help plugins' to see a list of options, and see "
|
||||||
|
" https://eff.org/letsencrypt-plugins for more detail on what the plugins "
|
||||||
|
"do and how to use them.")
|
||||||
|
|
||||||
if code == display_util.OK:
|
if code == display_util.OK:
|
||||||
plugin_ep = prepared[index]
|
plugin_ep = prepared[index]
|
||||||
|
|||||||
Reference in New Issue
Block a user