commit f91d1369627eac0c8c42b361f9f2131b62b65f80 Author: juga0 <juga> Date: Sat Sep 19 20:55:48 2015 +0000
add handleRead --- ooni/templates/process.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/ooni/templates/process.py b/ooni/templates/process.py index a3c74ff..7ec4b2e 100644 --- a/ooni/templates/process.py +++ b/ooni/templates/process.py @@ -59,12 +59,14 @@ class ProcessDirector(protocol.ProcessProtocol): self.stdout += data if self.shouldClose(): self.close("condition_met") + self.handleRead(data, None)
def errReceived(self, data): log.debug("STDERR: %s" % data) self.stderr += data if self.shouldClose(): self.close("condition_met") + self.handlRead(None, data)
def inConnectionLost(self): @@ -84,6 +86,9 @@ class ProcessDirector(protocol.ProcessProtocol): log.debug("Ended %s" % reason) self.finish("process_done")
+ def handleRead(self, stdout, stderr=None): + pass +
class ProcessTest(NetTestCase): name = "Base Process Test" @@ -110,5 +115,10 @@ class ProcessTest(NetTestCase): d = defer.Deferred() d.addCallback(self.processEnded, command) self.processDirector = ProcessDirector(d, finished, self.timeout) + self.processDirector.handleRead = self.handleRead reactor.spawnProcess(self.processDirector, command[0], command, env=env, path=path, usePTY=usePTY) return d + + # handleRead is not an abstract method to be backwards compatible + def handleRead(self, stdout, stderr=None): + pass
tor-commits@lists.torproject.org