Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from subprocess import Popen, PIPE
import json
def run_command(command):
command_process = Popen(command, stdout=PIPE, shell=True)
while True:
line = command_process.stdout.readline().rstrip()
if not line:
break
yield line
for line in run_command('tail -f file.log'):
print(json.load(line)['type'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.