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.
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