summaryrefslogtreecommitdiff
path: root/ec2init/execute.py
diff options
context:
space:
mode:
Diffstat (limited to 'ec2init/execute.py')
-rw-r--r--ec2init/execute.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/ec2init/execute.py b/ec2init/execute.py
new file mode 100644
index 00000000..d7386663
--- /dev/null
+++ b/ec2init/execute.py
@@ -0,0 +1,14 @@
+def run(list,cfg):
+ import subprocess
+ subprocess.Popen(list).communicate()
+ retcode = subprocess.call(list)
+
+ if retcode == 0:
+ return
+
+ if retcode < 0:
+ str="Cmd terminated by signal %s\n" % -retcode
+ else:
+ str="Cmd returned %s\n" % retcode
+ str+=' '.join(list)
+ raise Exception(str)