ENTRY | DOWNLOAD | MANUAL | ONGOING | |
ipc_ping.py"""Run another program and keep a bidirectional pipe open to communicate with it. by stephan) """ from slut import * from twisted.internet.protocol import ProcessProtocol class Atlantis(World): def onSetup(self): self.name = "Ping" self.width = 600 self.height = 100 self.font = font(12, 'courier') self.pingoutput = '' #some platforms may require to #specify the entire path to the program reactor.spawnProcess(Pro(), "ping", ["ping", "google.com"], {}) def onDrawOrtho(self): text(self.pingoutput, self.font, 10, 50) class Pro(ProcessProtocol): def connectionMade(self): print "connectionMade" print "self.transport.write(text) can now print "be used to write to the process." def outReceived(self, data): glo.world.pingoutput = data[:-1] atlantis = Atlantis() atlantis.run() |
|
Initiated by Stephan Hechenberger Thanks to CADRE's 103 |