Add pysawsim.manager and pysawsim.manager.thread for running asynchronous jobs.
[sawsim.git] / pysawsim / invoke.py
index d7c10b5c778f9d38118be0cd2093fd9b17a01557..bb051d7ad8c36e17090d188dc2763800401a0915 100644 (file)
@@ -34,7 +34,7 @@ class CommandError(Exception):
         self.stdout = stdout
         self.stderr = stderr
 
-def invoke(cmd_string, stdin=None, expect=(0,), cwd=None, verbose=True):
+def invoke(cmd_string, stdin=None, expect=(0,), cwd=None, verbose=False):
     """
     expect should be a tuple of allowed exit codes.  cwd should be
     the directory from which the command will be executed.
@@ -51,11 +51,11 @@ def invoke(cmd_string, stdin=None, expect=(0,), cwd=None, verbose=True):
             q = Popen(cmd_string, stdin=PIPE, stdout=PIPE, stderr=PIPE,
                       shell=True, cwd=cwd)
     except OSError, e :
-        raise CommandError(args, status=e.args[0], stdout="", stderr=e)
-    output,error = q.communicate(input=stdin)
+        raise CommandError(cmd_string, status=e.args[0], stdout="", stderr=e)
+    stdout,stderr = q.communicate(input=stdin)
     status = q.wait()
     if verbose == True:
-        print >> sys.stderr, "%d\n%s%s" % (status, output, error)
+        print >> sys.stderr, "%d\n%s%s" % (status, stdout, stderr)
     if status not in expect:
-        raise CommandError(args, status, output, error)
-    return status, output, error
+        raise CommandError(cmd_string, status, stdout, stderr)
+    return status, stdout, stderr