mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] app_id is id in app list, not in yunohost
This commit is contained in:
parent
8edc5c1ae3
commit
b111c57aa5
2 changed files with 40 additions and 33 deletions
|
@ -780,18 +780,18 @@ app:
|
|||
### app_action_list()
|
||||
list:
|
||||
action_help: List app actions
|
||||
api: GET /apps/<app_id>/actions
|
||||
api: GET /apps/<app>/actions
|
||||
arguments:
|
||||
app_id:
|
||||
help: app id
|
||||
app:
|
||||
help: App name
|
||||
|
||||
### app_action_run()
|
||||
run:
|
||||
action_help: Run app action
|
||||
api: PUT /apps/<app_id>/actions/<action>
|
||||
api: PUT /apps/<app>/actions/<action>
|
||||
arguments:
|
||||
app_id:
|
||||
help: app id
|
||||
app:
|
||||
help: App name
|
||||
action:
|
||||
help: action id
|
||||
-a:
|
||||
|
@ -805,18 +805,18 @@ app:
|
|||
### app_config_show_panel()
|
||||
show-panel:
|
||||
action_help: show config panel for the application
|
||||
api: GET /apps/<app_id>/config-panel
|
||||
api: GET /apps/<app>/config-panel
|
||||
arguments:
|
||||
app_id:
|
||||
help: App ID
|
||||
app:
|
||||
help: App name
|
||||
|
||||
### app_config_apply()
|
||||
apply:
|
||||
action_help: apply the new configuration
|
||||
api: POST /apps/<app_id>/config
|
||||
api: POST /apps/<app>/config
|
||||
arguments:
|
||||
app_id:
|
||||
help: App ID
|
||||
app:
|
||||
help: App name
|
||||
-a:
|
||||
full: --args
|
||||
help: Serialized arguments for new configuration (i.e. "domain=domain.tld&path=/path")
|
||||
|
|
|
@ -1461,33 +1461,33 @@ def app_change_label(auth, app, new_label):
|
|||
# actions todo list:
|
||||
# * docstring
|
||||
|
||||
def app_action_list(app_id):
|
||||
def app_action_list(app):
|
||||
logger.warning(m18n.n('experimental_feature'))
|
||||
|
||||
# this will take care of checking if the app is installed
|
||||
app_info_dict = app_info(app_id)
|
||||
app_info_dict = app_info(app)
|
||||
|
||||
actions = os.path.join(APPS_SETTING_PATH, app_id, 'actions.json')
|
||||
actions = os.path.join(APPS_SETTING_PATH, app, 'actions.json')
|
||||
|
||||
return {
|
||||
"app_id": app_id,
|
||||
"app": app,
|
||||
"app_name": app_info_dict["name"],
|
||||
"actions": read_json(actions) if os.path.exists(actions) else [],
|
||||
}
|
||||
|
||||
|
||||
def app_action_run(app_id, action, args=None):
|
||||
def app_action_run(app, action, args=None):
|
||||
logger.warning(m18n.n('experimental_feature'))
|
||||
|
||||
from yunohost.hook import hook_exec
|
||||
import tempfile
|
||||
|
||||
# will raise if action doesn't exist
|
||||
actions = app_action_list(app_id)["actions"]
|
||||
actions = app_action_list(app)["actions"]
|
||||
actions = {x["id"]: x for x in actions}
|
||||
|
||||
if action not in actions:
|
||||
raise MoulinetteError(errno.EINVAL, "action '%s' not available for app '%s', available actions are: %s" % (action, app_id, ", ".join(actions.keys())))
|
||||
raise MoulinetteError(errno.EINVAL, "action '%s' not available for app '%s', available actions are: %s" % (action, app, ", ".join(actions.keys())))
|
||||
|
||||
action_declaration = actions[action]
|
||||
|
||||
|
@ -1508,9 +1508,9 @@ def app_action_run(app_id, action, args=None):
|
|||
os.chmod(path, 700)
|
||||
|
||||
if action_declaration.get("cwd"):
|
||||
cwd = action_declaration["cwd"].replace("$app_id", app_id)
|
||||
cwd = action_declaration["cwd"].replace("$app", app_id)
|
||||
else:
|
||||
cwd = "/etc/yunohost/apps/" + app_id
|
||||
cwd = "/etc/yunohost/apps/" + app
|
||||
|
||||
retcode = hook_exec(
|
||||
path,
|
||||
|
@ -1521,7 +1521,7 @@ def app_action_run(app_id, action, args=None):
|
|||
)
|
||||
|
||||
if retcode not in action_declaration.get("accepted_return_codes", [0]):
|
||||
raise MoulinetteError(retcode, "Error while executing action '%s' of app '%s': return code %s" % (action, app_id, retcode))
|
||||
raise MoulinetteError(retcode, "Error while executing action '%s' of app '%s': return code %s" % (action, app, retcode))
|
||||
|
||||
os.remove(path)
|
||||
|
||||
|
@ -1531,27 +1531,31 @@ def app_action_run(app_id, action, args=None):
|
|||
# Config panel todo list:
|
||||
# * docstrings
|
||||
# * merge translations on the json once the workflow is in place
|
||||
def app_config_show_panel(app_id):
|
||||
def app_config_show_panel(app):
|
||||
logger.warning(m18n.n('experimental_feature'))
|
||||
|
||||
from yunohost.hook import hook_exec
|
||||
|
||||
# this will take care of checking if the app is installed
|
||||
app_info_dict = app_info(app_id)
|
||||
app_info_dict = app_info(app)
|
||||
|
||||
config_panel = os.path.join(APPS_SETTING_PATH, app, 'config_panel.json')
|
||||
config_script = os.path.join(APPS_SETTING_PATH, app, 'scripts', 'config')
|
||||
|
||||
config_panel = os.path.join(APPS_SETTING_PATH, app_id, 'config_panel.json')
|
||||
config_script = os.path.join(APPS_SETTING_PATH, app_id, 'scripts', 'config')
|
||||
|
||||
if not os.path.exists(config_panel) or not os.path.exists(config_script):
|
||||
return {
|
||||
"app_id": app_id,
|
||||
"app": app,
|
||||
"app_name": app_info_dict["name"],
|
||||
"config_panel": [],
|
||||
}
|
||||
|
||||
config_panel = read_json(config_panel)
|
||||
|
||||
env = {"YNH_APP_ID": app_id}
|
||||
env = {
|
||||
"YNH_APP_ID": app,
|
||||
}
|
||||
parsed_values = {}
|
||||
|
||||
# I need to parse stdout to communicate between scripts because I can't
|
||||
|
@ -1608,23 +1612,24 @@ def app_config_show_panel(app_id):
|
|||
|
||||
return {
|
||||
"app_id": app_id,
|
||||
"app": app,
|
||||
"app_name": app_info_dict["name"],
|
||||
"config_panel": config_panel,
|
||||
}
|
||||
|
||||
|
||||
def app_config_apply(app_id, args):
|
||||
def app_config_apply(app, args):
|
||||
logger.warning(m18n.n('experimental_feature'))
|
||||
|
||||
from yunohost.hook import hook_exec
|
||||
|
||||
installed = _is_installed(app_id)
|
||||
installed = _is_installed(app)
|
||||
if not installed:
|
||||
raise MoulinetteError(errno.ENOPKG,
|
||||
m18n.n('app_not_installed', app=app_id))
|
||||
m18n.n('app_not_installed', app=app))
|
||||
|
||||
config_panel = os.path.join(APPS_SETTING_PATH, app_id, 'config_panel.json')
|
||||
config_script = os.path.join(APPS_SETTING_PATH, app_id, 'scripts', 'config')
|
||||
config_panel = os.path.join(APPS_SETTING_PATH, app, 'config_panel.json')
|
||||
config_script = os.path.join(APPS_SETTING_PATH, app, 'scripts', 'config')
|
||||
|
||||
if not os.path.exists(config_panel) or not os.path.exists(config_script):
|
||||
# XXX real exception
|
||||
|
@ -1632,7 +1637,9 @@ def app_config_apply(app_id, args):
|
|||
|
||||
config_panel = read_json(config_panel)
|
||||
|
||||
env = {"YNH_APP_ID": app_id}
|
||||
env = {
|
||||
"YNH_APP_ID": app,
|
||||
}
|
||||
args = dict(urlparse.parse_qsl(args, keep_blank_values=True)) if args else {}
|
||||
|
||||
for tab in config_panel.get("panel", []):
|
||||
|
|
Loading…
Add table
Reference in a new issue