From 405e60215ce135ef7e94803d25c34404d742a06e Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 2 Feb 2011 10:08:24 +1300 Subject: View script debug output (stderr) in pager. --- libmproxy/flow.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'libmproxy/flow.py') diff --git a/libmproxy/flow.py b/libmproxy/flow.py index c0b96c90..d3bba4b3 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -53,13 +53,19 @@ class Flow: def run_script(self, path): """ - Run a script on a flow, returning the modified flow. + Run a script on a flow. - Raises RunException if there's an error. + Returns a (flow, stderr output) tuple, or raises RunException if + there's an error. """ data = self.script_serialize() try: - p = subprocess.Popen([path], stdout=subprocess.PIPE, stdin=subprocess.PIPE) + p = subprocess.Popen( + [path], + stdout=subprocess.PIPE, + stdin=subprocess.PIPE, + stderr=subprocess.PIPE, + ) except OSError, e: raise RunException(e.args[1]) so, se = p.communicate(data) @@ -68,7 +74,7 @@ class Flow: f = Flow.script_deserialize(so) if not f: raise RunException("Invalid response from script.") - return f + return f, se def dump(self): data = dict( -- cgit v1.2.3