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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -