[Lldb-commits] [lldb] r226300 - Add a utility script that executes an inferior process tucking its output away somewhere safe, and not letting error messages escape

Enrico Granata egranata at apple.com
Fri Jan 16 10:59:55 PST 2015


Author: enrico
Date: Fri Jan 16 12:59:54 2015
New Revision: 226300

URL: http://llvm.org/viewvc/llvm-project?rev=226300&view=rev
Log:
Add a utility script that executes an inferior process tucking its output away somewhere safe, and not letting error messages escape
This has potential to be useful in build automation environments


Added:
    lldb/trunk/scripts/shush   (with props)

Added: lldb/trunk/scripts/shush
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/shush?rev=226300&view=auto
==============================================================================
--- lldb/trunk/scripts/shush (added)
+++ lldb/trunk/scripts/shush Fri Jan 16 12:59:54 2015
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+import sys
+import subprocess
+import tempfile
+import time
+
+def command():
+    return ' '.join(sys.argv[1:])
+
+def tmpfile(suffix=None):
+    return tempfile.NamedTemporaryFile(prefix='shush', suffix=suffix, delete=False)
+
+def launch(sin=None, sout=None, serr=None):
+    class Process(object):
+        def __init__(self, p, i, o, e):
+            self.p = p
+            self.stdin = i
+            self.stdout = o
+            self.stderr = e
+        
+        def poll(self):
+            self.returncode = self.p.poll()
+            return self.returncode
+
+    return Process(subprocess.Popen(command(), shell=True, stdin=sin, stdout=sout, stderr=serr), sin, sout, serr)
+
+def wait(p):
+    while p.poll() is None:
+        time.sleep(5)
+        print "still running..." # fool Xcode into thinking that I am doing something...
+    return p
+
+def exit(p):
+    code = p.returncode
+    if code != 0:
+        print "error: sucks to be you"
+        print ("error: shushed process failed - go check %s and %s for details" % (p.stdout.name, p.stderr.name))
+    sys.exit(code)
+
+def main():
+    out = tmpfile(suffix="stdout")
+    err = tmpfile(suffix="stderr")
+    p = wait(launch(sout=out, serr=err))
+    exit(p)
+
+main()

Propchange: lldb/trunk/scripts/shush
------------------------------------------------------------------------------
    svn:executable = *





More information about the lldb-commits mailing list