Skip to content

Instantly share code, notes, and snippets.

@vayn
Created Dec 11, 2014
Embed
What would you like to do?
import sys
import subprocess
from time import sleep
cmd = ['top', '-l 0']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(p.stdout.readline, b''):
sys.stdout.write("\r" + line.decode().replace('\n', ''))
sys.stdout.flush()
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment