mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Upgrade + info bugfixes
This commit is contained in:
parent
94ff91f24f
commit
d127f7e7df
2 changed files with 36 additions and 17 deletions
|
@ -185,20 +185,21 @@ def app_info(app, raw=False):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
app_info = app_list(filter=app, raw=True)[app]
|
app_info = app_list(filter=app, raw=True)[app]
|
||||||
except YunoHostError:
|
except:
|
||||||
app_info = {}
|
app_info = {}
|
||||||
|
|
||||||
with open(apps_setting_path + app +'/settings.yml') as f:
|
if _is_installed(app):
|
||||||
app_info['settings'] = yaml.load(f)
|
with open(apps_setting_path + app +'/settings.yml') as f:
|
||||||
|
app_info['settings'] = yaml.load(f)
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
return app_info
|
return app_info
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
'Name': app_info['manifest']['name'],
|
'Name': app_info['manifest']['name'],
|
||||||
'Description': app_info['manifest']['description']['en'],
|
'Description': app_info['manifest']['description']['en'],
|
||||||
#TODO: Add more infos
|
#TODO: Add more infos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def app_map(app=None, raw=False, user=None):
|
def app_map(app=None, raw=False, user=None):
|
||||||
|
@ -264,6 +265,8 @@ def app_upgrade(app, url=None, file=None):
|
||||||
# If no app is specified, upgrade all apps
|
# If no app is specified, upgrade all apps
|
||||||
if not app:
|
if not app:
|
||||||
app = os.listdir(apps_setting_path)
|
app = os.listdir(apps_setting_path)
|
||||||
|
elif not isinstance(app, list):
|
||||||
|
app = [ app ]
|
||||||
|
|
||||||
for app_id in app:
|
for app_id in app:
|
||||||
installed = _is_installed(app_id)
|
installed = _is_installed(app_id)
|
||||||
|
@ -273,9 +276,13 @@ def app_upgrade(app, url=None, file=None):
|
||||||
if app_id in upgraded_apps:
|
if app_id in upgraded_apps:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#TODO: fix that (and check for instance number)
|
if '__' in app_id:
|
||||||
current_app_dict = app_info(app_id, instance=number, raw=True)
|
original_app_id = app_id[:app_id.index('__')]
|
||||||
new_app_dict = app_info(app_id, raw=True)
|
else:
|
||||||
|
original_app_id = app_id
|
||||||
|
|
||||||
|
current_app_dict = app_info(app_id, raw=True)
|
||||||
|
new_app_dict = app_info(original_app_id, raw=True)
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
manifest = _extract_app_from_file(file)
|
manifest = _extract_app_from_file(file)
|
||||||
|
@ -288,8 +295,20 @@ def app_upgrade(app, url=None, file=None):
|
||||||
|
|
||||||
app_setting_path = apps_setting_path +'/'+ app_id
|
app_setting_path = apps_setting_path +'/'+ app_id
|
||||||
|
|
||||||
|
if original_app_id != app_id:
|
||||||
|
# Replace original_app_id with the forked one in scripts
|
||||||
|
for file in os.listdir(app_tmp_folder +'/scripts'):
|
||||||
|
#TODO: add hooks directory to the list
|
||||||
|
#TODO: do it with sed ?
|
||||||
|
if file[:1] != '.':
|
||||||
|
with open(app_tmp_folder +'/scripts/'+ file, "r") as sources:
|
||||||
|
lines = sources.readlines()
|
||||||
|
with open(app_tmp_folder +'/scripts/'+ file, "w") as sources:
|
||||||
|
for line in lines:
|
||||||
|
sources.write(re.sub(r''+ original_app_id +'', app_id, line))
|
||||||
|
|
||||||
# Execute App upgrade script
|
# Execute App upgrade script
|
||||||
if hook_exec(app_setting_path+ '/scripts/upgrade') != 0:
|
if hook_exec(app_tmp_folder +'/scripts/upgrade') != 0:
|
||||||
#TODO: display fail messages from script
|
#TODO: display fail messages from script
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -205,7 +205,7 @@ def domain_add(domains, main=False):
|
||||||
raise YunoHostError(169, _("An error occured during domain creation"))
|
raise YunoHostError(169, _("An error occured during domain creation"))
|
||||||
|
|
||||||
|
|
||||||
os.system('yunohost app ssowatconf')
|
os.system('yunohost app ssowatconf > /dev/null 2>&1')
|
||||||
|
|
||||||
win_msg(_("Domain(s) successfully created"))
|
win_msg(_("Domain(s) successfully created"))
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ def domain_remove(domains):
|
||||||
else:
|
else:
|
||||||
raise YunoHostError(169, _("An error occured during domain deletion"))
|
raise YunoHostError(169, _("An error occured during domain deletion"))
|
||||||
|
|
||||||
os.system('yunohost app ssowatconf')
|
os.system('yunohost app ssowatconf > /dev/null 2>&1')
|
||||||
|
|
||||||
win_msg(_("Domain(s) successfully deleted"))
|
win_msg(_("Domain(s) successfully deleted"))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue