[enh] Enable ynh_info by default

This commit is contained in:
ljf 2018-06-11 11:56:54 +02:00
parent 7c28ec1c1b
commit 8e8d8e54ab
2 changed files with 8 additions and 14 deletions

View file

@ -490,8 +490,7 @@ def app_change_url(auth, app, domain, path):
# XXX journal # XXX journal
if hook_exec(os.path.join(APP_TMP_FOLDER, 'scripts/change_url'), if hook_exec(os.path.join(APP_TMP_FOLDER, 'scripts/change_url'),
args=args_list, env=env_dict, user="root", args=args_list, env=env_dict, user="root") != 0:
enable_stdinfo=True) != 0:
logger.error("Failed to change '%s' url." % app) logger.error("Failed to change '%s' url." % app)
# restore values modified by app_checkurl # restore values modified by app_checkurl
@ -606,8 +605,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
# Execute App upgrade script # Execute App upgrade script
os.system('chown -hR admin: %s' % INSTALL_TMP) os.system('chown -hR admin: %s' % INSTALL_TMP)
if hook_exec(extracted_app_folder + '/scripts/upgrade', if hook_exec(extracted_app_folder + '/scripts/upgrade',
args=args_list, env=env_dict, user="root", args=args_list, env=env_dict, user="root") != 0:
enable_stdinfo=True) != 0:
logger.error(m18n.n('app_upgrade_failed', app=app_instance_name)) logger.error(m18n.n('app_upgrade_failed', app=app_instance_name))
else: else:
now = int(time.time()) now = int(time.time())
@ -742,7 +740,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
try: try:
install_retcode = hook_exec( install_retcode = hook_exec(
os.path.join(extracted_app_folder, 'scripts/install'), os.path.join(extracted_app_folder, 'scripts/install'),
args=args_list, env=env_dict, user="root", enable_stdinfo=True) args=args_list, env=env_dict, user="root")
except (KeyboardInterrupt, EOFError): except (KeyboardInterrupt, EOFError):
install_retcode = -1 install_retcode = -1
except: except:
@ -759,8 +757,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
# Execute remove script # Execute remove script
remove_retcode = hook_exec( remove_retcode = hook_exec(
os.path.join(extracted_app_folder, 'scripts/remove'), os.path.join(extracted_app_folder, 'scripts/remove'),
args=[app_instance_name], env=env_dict_remove, user="root", args=[app_instance_name], env=env_dict_remove, user="root")
enable_stdinfo=True)
if remove_retcode != 0: if remove_retcode != 0:
logger.warning(m18n.n('app_not_properly_removed', logger.warning(m18n.n('app_not_properly_removed',
app=app_instance_name)) app=app_instance_name))
@ -832,7 +829,7 @@ def app_remove(auth, app):
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb) env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb)
if hook_exec('/tmp/yunohost_remove/scripts/remove', args=args_list, if hook_exec('/tmp/yunohost_remove/scripts/remove', args=args_list,
env=env_dict, user="root", enable_stdinfo=True) == 0: env=env_dict, user="root") == 0:
logger.success(m18n.n('app_removed', app=app)) logger.success(m18n.n('app_removed', app=app))
if os.path.exists(app_setting_path): if os.path.exists(app_setting_path):

View file

@ -298,7 +298,7 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
def hook_exec(path, args=None, raise_on_error=False, no_trace=False, def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
chdir=None, env=None, user="admin", enable_stdinfo=False): chdir=None, env=None, user="admin"):
""" """
Execute hook from a file with arguments Execute hook from a file with arguments
@ -337,11 +337,8 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
env = {} env = {}
env['YNH_CWD'] = chdir env['YNH_CWD'] = chdir
if enable_stdinfo: stdinfo = os.path.join(tempfile.mkdtemp(), "stdinfo")
stdinfo = os.path.join(tempfile.mkdtemp(), "stdinfo") env['YNH_STDINFO'] = stdinfo
env['YNH_STDINFO'] = stdinfo
else:
stdinfo = None
# Construct command to execute # Construct command to execute
if user == "root": if user == "root":