Advertisement
rajkosto

Untitled

Jun 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def realtime_run(totalArgs):
  2.     process = subprocess.Popen(totalArgs, bufsize=0, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
  3.     while True:
  4.         nextline = process.stdout.readline()
  5.         if nextline == '' and process.poll() is not None:
  6.             break
  7.         sys.stdout.write(nextline)
  8.         sys.stdout.flush()
  9.  
  10.     output = process.communicate()[0]
  11.     exitCode = process.returncode
  12.  
  13.     if (exitCode == 0):
  14.         return output
  15.     else:
  16.         raise subprocess.CalledProcessError(exitCode, " ".join(totalArgs), output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement