| 1 | |
|---|
| 2 | import sys |
|---|
| 3 | from twisted.internet import protocol |
|---|
| 4 | from twisted.internet import reactor |
|---|
| 5 | |
|---|
| 6 | class MyPP(protocol.ProcessProtocol): |
|---|
| 7 | def __init__(self, verses): |
|---|
| 8 | self.verses = verses |
|---|
| 9 | self.data = "" |
|---|
| 10 | def connectionMade(self): |
|---|
| 11 | print "connectionMade!" |
|---|
| 12 | self.transport.closeStdin() # tell them we're done |
|---|
| 13 | def outReceived(self, data): |
|---|
| 14 | self.data = self.data + data |
|---|
| 15 | def errReceived(self, data): |
|---|
| 16 | self.data = self.data + data |
|---|
| 17 | def processEnded(self, status_object): |
|---|
| 18 | print "processEnded, status %d" % status_object.value.exitCode |
|---|
| 19 | print "quitting" |
|---|
| 20 | print self.data |
|---|
| 21 | reactor.stop() |
|---|
| 22 | |
|---|
| 23 | def starter(): |
|---|
| 24 | pp = MyPP(10) |
|---|
| 25 | reactor.spawnProcess(pp, sys.executable, [sys.executable, "openSocketChild.py"], {}) |
|---|
| 26 | |
|---|
| 27 | reactor.callLater(0, starter) |
|---|
| 28 | |
|---|
| 29 | from twisted.application import service |
|---|
| 30 | application = service.Application('pydapserver') |
|---|
| 31 | |
|---|