oe.process: allow passing input into run()
authorChris Larson <chris_larson@mentor.com>
Fri, 22 Oct 2010 00:23:27 +0000 (17:23 -0700)
committerChris Larson <chris_larson@mentor.com>
Fri, 22 Oct 2010 01:52:06 +0000 (18:52 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/oe/process.py

index 63b1457..26c3e65 100644 (file)
@@ -55,7 +55,7 @@ class Popen(subprocess.Popen):
         options.update(kwargs)
         subprocess.Popen.__init__(self, *args, **options)
 
-def run(cmd, **options):
+def run(cmd, input=None, **options):
     """Convenience function to run a command and return its output, raising an
     exception when the command fails"""
 
@@ -68,7 +68,7 @@ def run(cmd, **options):
             raise NotFoundError(cmd)
         else:
             raise
-    stdout, stderr = pipe.communicate()
+    stdout, stderr = pipe.communicate(input)
     if pipe.returncode != 0:
         raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
     return stdout