Clone of official tools

Revision:
21:4fdf0dd04f6f
Parent:
19:3604ee113e2d
Child:
22:9e85236d8716
diff -r 835f6355470d -r 4fdf0dd04f6f utils.py
--- a/utils.py	Fri Jul 15 15:28:09 2016 +0100
+++ b/utils.py	Fri Jul 15 22:58:15 2016 +0100
@@ -25,6 +25,27 @@
 from collections import OrderedDict
 import logging
 
+def compile_worker(job):
+    results = []
+    for command in job['commands']:
+        try:
+            _, _stderr, _rc = run_cmd(command, work_dir=job['work_dir'], chroot=job['chroot'])
+        except KeyboardInterrupt as e:
+            raise ToolException
+
+        results.append({
+            'code': _rc,
+            'output': _stderr,
+            'command': command
+        })
+
+    return {
+        'source': job['source'],
+        'object': job['object'],
+        'commands': job['commands'],
+        'results': results
+    }
+
 def cmd(l, check=True, verbose=False, shell=False, cwd=None):
     text = l if shell else ' '.join(l)
     if verbose:
@@ -45,9 +66,8 @@
 
         logging.debug("Running command %s"%' '.join(chroot_cmd))
         command = chroot_cmd
-        work_dir = chroot
+        work_dir = None
 
-    assert is_cmd_valid(command[0])
     try:
         p = Popen(command, stdout=PIPE, stderr=STDOUT if redirect else PIPE, cwd=work_dir)
         _stdout, _stderr = p.communicate()