From 33de61586b923f58bf1c344be7c3cf5c93f36bae Mon Sep 17 00:00:00 2001 From: kload Date: Sat, 24 May 2014 19:26:28 +0000 Subject: [PATCH] [enh] Use subprocess to see script execution in details --- hook.py | 11 ++++++++++- locales/en.json | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hook.py b/hook.py index b57183f26..762d996c2 100644 --- a/hook.py +++ b/hook.py @@ -28,6 +28,7 @@ import sys import re import json import errno +import subprocess from moulinette.core import MoulinetteError @@ -179,5 +180,13 @@ def hook_exec(file, args=None): if "/" in file and file[0:2] != file_path: file_path = os.path.dirname(file) file = file.replace(file_path +"/", "") - return os.system('su - admin -c "cd \\"%s\\" && bash \\"%s\\" %s"' % (file_path, file, ' '.join(arg_list))) + msignals.display(m18n.n('executing_script')) #TODO: Allow python script + p = subprocess.Popen('su - admin -c "cd \\"%s\\" && /bin/bash -x \\"%s\\" %s"' % (file_path, file, ' '.join(arg_list)), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + for line in iter(p.stdout.readline, ''): + line = line.rstrip() + msignals.display(line, 'log') + errorcode = p.poll() + p.stdout.close() + + return errorcode diff --git a/locales/en.json b/locales/en.json index 96796b616..1d824c5db 100644 --- a/locales/en.json +++ b/locales/en.json @@ -34,6 +34,7 @@ "mysql_db_initialized" : "MySQL database successfully initialized", "extracting" : "Extracting...", "downloading" : "Downloading...", + "executing_script": "Executing script...", "done" : "Done.", "domain_unknown" : "Unknown domain",