mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix code that was half broken because of undefined vars :|
This commit is contained in:
parent
4286523653
commit
5f242aea18
1 changed files with 21 additions and 21 deletions
|
@ -2477,7 +2477,7 @@ def _parse_args_in_yunohost_format(user_answers, argument_questions):
|
||||||
or config_panel.json/toml
|
or config_panel.json/toml
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import domain_list, _get_maindomain
|
from yunohost.domain import domain_list, _get_maindomain
|
||||||
from yunohost.user import user_list
|
from yunohost.user import user_list, user_info
|
||||||
|
|
||||||
parsed_answers_dict = OrderedDict()
|
parsed_answers_dict = OrderedDict()
|
||||||
|
|
||||||
|
@ -2503,27 +2503,9 @@ def _parse_args_in_yunohost_format(user_answers, argument_questions):
|
||||||
question_value = user_answers[question_name]
|
question_value = user_answers[question_name]
|
||||||
else:
|
else:
|
||||||
if 'ask' in question:
|
if 'ask' in question:
|
||||||
# Retrieve proper ask string
|
|
||||||
text_for_user_input_in_cli = _value_for_locale(question['ask'])
|
|
||||||
|
|
||||||
# Append extra strings
|
|
||||||
if question_type == 'boolean':
|
|
||||||
text_for_user_input_in_cli += ' [yes | no]'
|
|
||||||
elif question_choices:
|
|
||||||
text_for_user_input_in_cli += ' [{0}]'.format(' | '.join(question_choices))
|
|
||||||
|
|
||||||
if question_default is not None:
|
|
||||||
if question_type == 'boolean':
|
|
||||||
text_for_user_input_in_cli += ' (default: {0})'.format("yes" if question_default == 1 else "no")
|
|
||||||
else:
|
|
||||||
text_for_user_input_in_cli += ' (default: {0})'.format(question_default)
|
|
||||||
|
|
||||||
# Check for a password argument
|
|
||||||
is_password = True if question_type == 'password' else False
|
|
||||||
|
|
||||||
if question_type == 'domain':
|
if question_type == 'domain':
|
||||||
question_default = _get_maindomain()
|
question_default = _get_maindomain()
|
||||||
text_for_user_input_in_cli += ' (default: {0})'.format(question_default)
|
|
||||||
msignals.display(m18n.n('domains_available'))
|
msignals.display(m18n.n('domains_available'))
|
||||||
for domain in domain_list()['domains']:
|
for domain in domain_list()['domains']:
|
||||||
msignals.display("- {}".format(domain))
|
msignals.display("- {}".format(domain))
|
||||||
|
@ -2537,12 +2519,30 @@ def _parse_args_in_yunohost_format(user_answers, argument_questions):
|
||||||
root_mail = "root@%s" % _get_maindomain()
|
root_mail = "root@%s" % _get_maindomain()
|
||||||
for user in users.keys():
|
for user in users.keys():
|
||||||
if root_mail in user_info(user)["mail-aliases"]:
|
if root_mail in user_info(user)["mail-aliases"]:
|
||||||
arg_default = user
|
question_default = user
|
||||||
ask_string += ' (default: {0})'.format(arg_default)
|
break
|
||||||
|
|
||||||
elif question_type == 'password':
|
elif question_type == 'password':
|
||||||
msignals.display(m18n.n('good_practices_about_user_password'))
|
msignals.display(m18n.n('good_practices_about_user_password'))
|
||||||
|
|
||||||
|
# Retrieve proper ask string
|
||||||
|
text_for_user_input_in_cli = _value_for_locale(question['ask'])
|
||||||
|
|
||||||
|
# Append extra strings
|
||||||
|
if question_type == 'boolean':
|
||||||
|
text_for_user_input_in_cli += ' [yes | no]'
|
||||||
|
elif question_choices:
|
||||||
|
text_for_user_input_in_cli += ' [{0}]'.format(' | '.join(question_choices))
|
||||||
|
|
||||||
|
|
||||||
|
if question_default is not None:
|
||||||
|
if question_type == 'boolean':
|
||||||
|
text_for_user_input_in_cli += ' (default: {0})'.format("yes" if question_default == 1 else "no")
|
||||||
|
else:
|
||||||
|
text_for_user_input_in_cli += ' (default: {0})'.format(question_default)
|
||||||
|
|
||||||
|
is_password = True if question_type == 'password' else False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
input_string = msignals.prompt(text_for_user_input_in_cli, is_password)
|
input_string = msignals.prompt(text_for_user_input_in_cli, is_password)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue