[llvm-commits] [zorg] r141465 - /zorg/trunk/lnt/lnt/testing/util/commands.py

Daniel Dunbar daniel at zuster.org
Fri Oct 7 18:01:31 PDT 2011


Author: ddunbar
Date: Fri Oct  7 20:01:30 2011
New Revision: 141465

URL: http://llvm.org/viewvc/llvm-project?rev=141465&view=rev
Log:
lnt.testing.util.commands: Add a capture_with_result() function.

Modified:
    zorg/trunk/lnt/lnt/testing/util/commands.py

Modified: zorg/trunk/lnt/lnt/testing/util/commands.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/commands.py?rev=141465&r1=141464&r2=141465&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/testing/util/commands.py (original)
+++ zorg/trunk/lnt/lnt/testing/util/commands.py Fri Oct  7 20:01:30 2011
@@ -50,10 +50,12 @@
         if e.errno != errno.EEXIST:
             raise
 
-def capture(args, include_stderr=False):
+def capture_with_result(args, include_stderr=False):
     import subprocess
-    """capture(command) - Run the given command (or argv list) in a shell and
-    return the standard output."""
+    """capture_with_result(command) -> (output, exit code)
+
+    Run the given command (or argv list) in a shell and return the standard
+    output and exit code."""
     stderr = subprocess.PIPE
     if include_stderr:
         stderr = subprocess.STDOUT
@@ -64,7 +66,13 @@
             fatal('no such file or directory: %r' % args[0])
         raise
     out,_ = p.communicate()
-    return out
+    return out,p.wait()
+
+def capture(args, include_stderr=False):
+    import subprocess
+    """capture(command) - Run the given command (or argv list) in a shell and
+    return the standard output."""
+    return capture_with_result(args, include_stderr)[0]
 
 def which(command, paths = None):
     """which(command, [paths]) - Look up the given command in the paths string





More information about the llvm-commits mailing list