[Twisted-Python] getProcessOutpout

Philippe Lafoucrière lafou at wanadoo.fr
Sun Nov 30 11:17:36 MST 2003


I have a pb with twisted.internet.utils.getProcessOutput (i never get the 
output :() here is an exemple :

class PGAT_deftest(GAT_page):

    template="""<html><body><span view="Viewtest"></span></body></html>"""

    def wvfactory_Viewtest(self, request, node, model):
        return MyDeferredWidget(model)

    def render(self, request):
        request.write('<html><body><h1>DEFTEST</h1>'+ time.asctime()+'<br >')
        print "Emerge !"
        d = getProcessOutput("ps")
        d.setTimeout(5,self.renderProcessOutput, request)
        d.addCallback(self.renderProcessOutput, request)
        d.addErrback(self.renderError, request)
        d.addCallback(self.finishPage, request)
        return NOT_DONE_YET

    def renderProcessOutput(self, output, request):
        request.write(output)

    def renderError(self, failure, request):
        request.write('it broke! (error : "'+failure.getErrorMessage()+'")')

    def finishPage(self, _, request):
        request.write('</body></html>')
        request.finish()

def montest():
    time.sleep(5)
    return "Ca marche !"

If I create a bash script with :
---
sleep(5)
echo "Hello world"
---
the twisted code above works great. But If I use a system program like "ps" or 
"emerge" , the callback is never called :(

(btw : getProcessOutput ("date") works)





More information about the Twisted-Python mailing list