python - How can I serve a (never ending) system call with Tornado -
for instance, suppose have code:
def dump(): tcpdump = subprocess.popen("tcpdump -nli any", stdin=subprocess.pipe, stdout=subprocess.pipe, shell=true) outputfile = tcpdump.stdout line in outputfile: print line,
how can serve output of such browser? since there no stopping point, have no idea hook polling loop. more that, print line works (i see lines dumped on terminal), browser not same lines, see below:
class tcpdumphandler(tornado.web.requesthandler): def get(self): self.write("<form method='post' action='/log'><input type='submit'></form>") @tornado.web.asynchronous def post(self): tcpdump = subprocess.popen("tcpdump -nli any", stdin=subprocess.pipe, stdout=subprocess.pipe, shell=true) outputfile = tcpdump.stdout line in outputfile: print line, self.write(line) self.finish()
redirect tcpdump's output file , use this:
https://bitbucket.org/silverspell/tornadolog
hope helps :)
Comments
Post a Comment