summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba/samba_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools/wafsamba/samba_utils.py')
-rw-r--r--buildtools/wafsamba/samba_utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index a5d42e4f7f..cb055043a7 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -296,3 +296,21 @@ def mkdir_p(dir):
return
mkdir_p(os.path.dirname(dir))
os.mkdir(dir)
+
+
+def RUN_COMMAND(cmd,
+ env=None,
+ shell=False):
+ '''run a external command, return exit code or signal'''
+ # recursively expand variables
+ if env:
+ while cmd.find('${') != -1:
+ cmd = Utils.subst_vars(cmd, env)
+
+ status = os.system(cmd)
+ if os.WIFEXITED(status):
+ return os.WEXITSTATUS(status)
+ if os.WIFSIGNALED(status):
+ return - os.WTERMSIG(status)
+ print "Unknown exit reason %d for command: %s" (status, cmd)
+ return -1