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

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

mysql - How to insert just year and month into date field? -