I have the following external asynchronous code, that I need to run from my python script (external.js):
var i = o
setInterval(function(){
i++;
console.log('item ' + i);//I need to evoke processOutput function on every console.log
}, 1000)
What I need to do in my python script is to catch every output portion(console.log) from external script and handle it:
import subprocess
def processOutput( consoleLogFromExternal )
#do stuff
proc = subprocess.Popen(['phantomjs', 'external.js'],
stdout=processOutput) #doesn't work, of course
Are there any ways to do this? Solution on Python 2.7 would be great.