mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Misc tweaks to handle new install questions format
This commit is contained in:
parent
953eb0cc1d
commit
56ac85af37
2 changed files with 31 additions and 51 deletions
|
@ -95,7 +95,6 @@ APP_FILES_TO_COPY = [
|
||||||
"doc",
|
"doc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def app_list(full=False, installed=False, filter=None):
|
def app_list(full=False, installed=False, filter=None):
|
||||||
"""
|
"""
|
||||||
List installed apps
|
List installed apps
|
||||||
|
@ -161,8 +160,8 @@ def app_info(app, full=False):
|
||||||
|
|
||||||
ret["setting_path"] = setting_path
|
ret["setting_path"] = setting_path
|
||||||
ret["manifest"] = local_manifest
|
ret["manifest"] = local_manifest
|
||||||
ret["manifest"]["arguments"] = _set_default_ask_questions(
|
ret["manifest"]["install"] = _set_default_ask_questions(
|
||||||
ret["manifest"].get("arguments", {})
|
ret["manifest"].get("install", {})
|
||||||
)
|
)
|
||||||
ret["settings"] = settings
|
ret["settings"] = settings
|
||||||
|
|
||||||
|
@ -179,7 +178,7 @@ def app_info(app, full=False):
|
||||||
os.path.join(setting_path, "scripts", "backup")
|
os.path.join(setting_path, "scripts", "backup")
|
||||||
) and os.path.exists(os.path.join(setting_path, "scripts", "restore"))
|
) and os.path.exists(os.path.join(setting_path, "scripts", "restore"))
|
||||||
ret["supports_multi_instance"] = is_true(
|
ret["supports_multi_instance"] = is_true(
|
||||||
local_manifest.get("multi_instance", False)
|
local_manifest.get("integration", {}).get("multi_instance", False)
|
||||||
)
|
)
|
||||||
ret["supports_config_panel"] = os.path.exists(
|
ret["supports_config_panel"] = os.path.exists(
|
||||||
os.path.join(setting_path, "config_panel.toml")
|
os.path.join(setting_path, "config_panel.toml")
|
||||||
|
@ -836,13 +835,13 @@ def app_install(
|
||||||
# If packaging_format v2+, save all install questions as settings
|
# If packaging_format v2+, save all install questions as settings
|
||||||
packaging_format = int(manifest.get("packaging_format", 0))
|
packaging_format = int(manifest.get("packaging_format", 0))
|
||||||
if packaging_format >= 2:
|
if packaging_format >= 2:
|
||||||
for arg_name, arg_value_and_type in args_odict.items():
|
for arg_name, arg_value in args.items():
|
||||||
|
|
||||||
# ... except is_public because it should not be saved and should only be about initializing permisisons
|
# ... except is_public ....
|
||||||
if arg_name == "is_public":
|
if arg_name == "is_public":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
app_settings[arg_name] = arg_value_and_type[0]
|
app_settings[arg_name] = arg_value
|
||||||
|
|
||||||
_set_app_settings(app_instance_name, app_settings)
|
_set_app_settings(app_instance_name, app_settings)
|
||||||
|
|
||||||
|
@ -1751,15 +1750,7 @@ def _get_app_actions(app_id):
|
||||||
for key, value in toml_actions.items():
|
for key, value in toml_actions.items():
|
||||||
action = dict(**value)
|
action = dict(**value)
|
||||||
action["id"] = key
|
action["id"] = key
|
||||||
|
action["arguments"] = value.get("arguments", {})
|
||||||
arguments = []
|
|
||||||
for argument_name, argument in value.get("arguments", {}).items():
|
|
||||||
argument = dict(**argument)
|
|
||||||
argument["name"] = argument_name
|
|
||||||
|
|
||||||
arguments.append(argument)
|
|
||||||
|
|
||||||
action["arguments"] = arguments
|
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
|
|
||||||
return actions
|
return actions
|
||||||
|
@ -2015,21 +2006,19 @@ def _convert_v1_manifest_to_v2(manifest):
|
||||||
return manifest
|
return manifest
|
||||||
|
|
||||||
|
|
||||||
def _set_default_ask_questions(arguments):
|
def _set_default_ask_questions(questions, script_name="install"):
|
||||||
|
|
||||||
# arguments is something like
|
# arguments is something like
|
||||||
# { "install": [
|
# { "domain":
|
||||||
# { "name": "domain",
|
# {
|
||||||
# "type": "domain",
|
# "type": "domain",
|
||||||
# ....
|
# ....
|
||||||
# },
|
# },
|
||||||
# { "name": "path",
|
# "path": {
|
||||||
# "type": "path"
|
# "type": "path",
|
||||||
# ...
|
# ...
|
||||||
# },
|
# },
|
||||||
# ...
|
# ...
|
||||||
# ],
|
|
||||||
# "upgrade": [ ... ]
|
|
||||||
# }
|
# }
|
||||||
|
|
||||||
# We set a default for any question with these matching (type, name)
|
# We set a default for any question with these matching (type, name)
|
||||||
|
@ -2041,38 +2030,29 @@ def _set_default_ask_questions(arguments):
|
||||||
("path", "path"), # i18n: app_manifest_install_ask_path
|
("path", "path"), # i18n: app_manifest_install_ask_path
|
||||||
("password", "password"), # i18n: app_manifest_install_ask_password
|
("password", "password"), # i18n: app_manifest_install_ask_password
|
||||||
("user", "admin"), # i18n: app_manifest_install_ask_admin
|
("user", "admin"), # i18n: app_manifest_install_ask_admin
|
||||||
("boolean", "is_public"),
|
("boolean", "is_public"), # i18n: app_manifest_install_ask_is_public
|
||||||
] # i18n: app_manifest_install_ask_is_public
|
]
|
||||||
|
|
||||||
for script_name, arg_list in arguments.items():
|
for question_name, question in questions.items():
|
||||||
|
question["name"] = question_name
|
||||||
|
|
||||||
# We only support questions for install so far, and for other
|
# If this question corresponds to a question with default ask message...
|
||||||
if script_name != "install":
|
if any(
|
||||||
continue
|
(question.get("type"), question["name"]) == q
|
||||||
|
for q in questions_with_default
|
||||||
for arg in arg_list:
|
):
|
||||||
|
# The key is for example "app_manifest_install_ask_domain"
|
||||||
# Do not override 'ask' field if provided by app ?... Or shall we ?
|
key = "app_manifest_%s_ask_%s" % (script_name, question["name"])
|
||||||
# if "ask" in arg:
|
question["ask"] = m18n.n(key)
|
||||||
# continue
|
|
||||||
|
|
||||||
# If this arg corresponds to a question with default ask message...
|
|
||||||
if any(
|
|
||||||
(arg.get("type"), arg["name"]) == question
|
|
||||||
for question in questions_with_default
|
|
||||||
):
|
|
||||||
# The key is for example "app_manifest_install_ask_domain"
|
|
||||||
key = "app_manifest_%s_ask_%s" % (script_name, arg["name"])
|
|
||||||
arg["ask"] = m18n.n(key)
|
|
||||||
|
|
||||||
# Also it in fact doesn't make sense for any of those questions to have an example value nor a default value...
|
# Also it in fact doesn't make sense for any of those questions to have an example value nor a default value...
|
||||||
if arg.get("type") in ["domain", "user", "password"]:
|
if question.get("type") in ["domain", "user", "password"]:
|
||||||
if "example" in arg:
|
if "example" in arg:
|
||||||
del arg["example"]
|
del question["example"]
|
||||||
if "default" in arg:
|
if "default" in arg:
|
||||||
del arg["domain"]
|
del question["domain"]
|
||||||
|
|
||||||
return arguments
|
return questions
|
||||||
|
|
||||||
|
|
||||||
def _is_app_repo_url(string: str) -> bool:
|
def _is_app_repo_url(string: str) -> bool:
|
||||||
|
@ -2306,7 +2286,7 @@ def _check_manifest_requirements(manifest: Dict):
|
||||||
"""Check if required packages are met from the manifest"""
|
"""Check if required packages are met from the manifest"""
|
||||||
|
|
||||||
packaging_format = int(manifest.get("packaging_format", 0))
|
packaging_format = int(manifest.get("packaging_format", 0))
|
||||||
if packaging_format not in [0, 1]:
|
if packaging_format not in [2]:
|
||||||
raise YunohostValidationError("app_packaging_format_not_supported")
|
raise YunohostValidationError("app_packaging_format_not_supported")
|
||||||
|
|
||||||
requirements = manifest.get("requirements", dict())
|
requirements = manifest.get("requirements", dict())
|
||||||
|
|
|
@ -58,8 +58,8 @@ def app_catalog(full=False, with_categories=False):
|
||||||
"level": infos["level"],
|
"level": infos["level"],
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
infos["manifest"]["arguments"] = _set_default_ask_questions(
|
infos["manifest"]["install"] = _set_default_ask_questions(
|
||||||
infos["manifest"].get("arguments", {})
|
infos["manifest"].get("install", {})
|
||||||
)
|
)
|
||||||
|
|
||||||
# Trim info for categories if not using --full
|
# Trim info for categories if not using --full
|
||||||
|
|
Loading…
Add table
Reference in a new issue