Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Portable command expansion.

  • Loading branch information...
commit 26bfc438d4182279bdd2e08856bf0f664387cd5b 1 parent 52219d7
Kenneth Reitz authored
Showing with 15 additions and 9 deletions.
  1. +15 −9 envoy/core.py
24 envoy/core.py
View
@@ -74,12 +74,8 @@ def __repr__(self):
else:
return '<Response>'
-
-def run(command, data=None, timeout=None):
- """Executes a given commmand and returns Response.
-
- Blocks until process is complete, or timeout is reached.
- """
+def prep_args(command):
+ """Parses command strings and returns a Popen-ready list."""
# Prepare arguments.
if isinstance(command, basestring):
@@ -95,14 +91,24 @@ def run(command, data=None, timeout=None):
break
command = map(shlex.split, command)
-
+
+ return command
+
+
+def run(command, data=None, timeout=None):
+ """Executes a given commmand and returns Response.
+
+ Blocks until process is complete, or timeout is reached.
+ """
+
+ command = prep_args(command)
+
history = []
for c in command:
if len(history):
# due to broken pipe problems pass only first 10MB
data = history[-1].std_out[0:10*1024]
-
cmd = Command(c)
out, err = cmd.run(data, timeout)
@@ -113,7 +119,7 @@ def run(command, data=None, timeout=None):
r.std_out = out
r.std_err = err
r.status_code = cmd.returncode
-
+
history.append(r)
Please sign in to comment.
Something went wrong with that request. Please try again.