mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Pass args to app install
This commit is contained in:
parent
9052d3be9f
commit
cddfc94666
3 changed files with 22 additions and 7 deletions
|
@ -294,6 +294,10 @@ app:
|
||||||
help: App to install
|
help: App to install
|
||||||
-l:
|
-l:
|
||||||
full: --label
|
full: --label
|
||||||
|
help: Custom name for the app
|
||||||
|
-a:
|
||||||
|
full: --args
|
||||||
|
help: Serialize arguments for app installation
|
||||||
|
|
||||||
### app_remove() TODO: Write help
|
### app_remove() TODO: Write help
|
||||||
remove:
|
remove:
|
||||||
|
|
|
@ -32,6 +32,7 @@ import yaml
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
|
import urlparse
|
||||||
from yunohost import YunoHostError, YunoHostLDAP, win_msg, random_password, is_true, validate
|
from yunohost import YunoHostError, YunoHostLDAP, win_msg, random_password, is_true, validate
|
||||||
from yunohost_domain import domain_list, domain_add
|
from yunohost_domain import domain_list, domain_add
|
||||||
from yunohost_user import user_info, user_list
|
from yunohost_user import user_info, user_list
|
||||||
|
@ -331,13 +332,14 @@ def app_upgrade(app, url=None, file=None):
|
||||||
win_msg(_("Upgrade complete"))
|
win_msg(_("Upgrade complete"))
|
||||||
|
|
||||||
|
|
||||||
def app_install(app, label=None):
|
def app_install(app, label=None, args=None):
|
||||||
"""
|
"""
|
||||||
Install apps
|
Install apps
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
label
|
label
|
||||||
app -- App to install
|
app -- App to install
|
||||||
|
args -- Serialize arguments of installation
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#TODO: Create tool for nginx (check path availability & stuff)
|
#TODO: Create tool for nginx (check path availability & stuff)
|
||||||
|
@ -398,8 +400,16 @@ def app_install(app, label=None):
|
||||||
app_setting(app_id, 'label', manifest['name'])
|
app_setting(app_id, 'label', manifest['name'])
|
||||||
|
|
||||||
os.system('chown -R admin: '+ app_tmp_folder)
|
os.system('chown -R admin: '+ app_tmp_folder)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if args is None:
|
||||||
|
args = ''
|
||||||
|
args_dict = dict(urlparse.parse_qsl(args))
|
||||||
|
except:
|
||||||
|
args_dict = {}
|
||||||
|
|
||||||
# Execute App install script
|
# Execute App install script
|
||||||
if hook_exec(app_tmp_folder + '/scripts/install') == 0:
|
if hook_exec(app_tmp_folder + '/scripts/install', args_dict) == 0:
|
||||||
# Move scripts and manifest to the right place
|
# Move scripts and manifest to the right place
|
||||||
os.system('mv "'+ app_tmp_folder +'/manifest.json" "'+ app_tmp_folder +'/scripts" '+ app_setting_path)
|
os.system('mv "'+ app_tmp_folder +'/manifest.json" "'+ app_tmp_folder +'/scripts" '+ app_setting_path)
|
||||||
shutil.rmtree(app_tmp_folder)
|
shutil.rmtree(app_tmp_folder)
|
||||||
|
@ -410,6 +420,7 @@ def app_install(app, label=None):
|
||||||
else:
|
else:
|
||||||
#TODO: display script fail messages
|
#TODO: display script fail messages
|
||||||
shutil.rmtree(app_setting_path)
|
shutil.rmtree(app_setting_path)
|
||||||
|
shutil.rmtree(app_tmp_folder)
|
||||||
raise YunoHostError(1, _("Installation failed"))
|
raise YunoHostError(1, _("Installation failed"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ def hook_exec(file, args=None):
|
||||||
elif os.isatty(1) and 'ask' in arg:
|
elif os.isatty(1) and 'ask' in arg:
|
||||||
arg_list.append(raw_input(colorize(arg['ask']['en'] + ': ', 'cyan'))) #TODO: I18n
|
arg_list.append(raw_input(colorize(arg['ask']['en'] + ': ', 'cyan'))) #TODO: I18n
|
||||||
else:
|
else:
|
||||||
raise YunoHostError(22, _("Missing arguments") + ': ' + arg_name)
|
raise YunoHostError(22, _("Missing arguments") + ': ' + arg['name'])
|
||||||
|
|
||||||
file_path = "./"
|
file_path = "./"
|
||||||
if "/" in file and file[0:2] != file_path:
|
if "/" in file and file[0:2] != file_path:
|
||||||
|
|
Loading…
Add table
Reference in a new issue