Advertisement
Guest User

Untitled

a guest
May 24th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1.  
  2. def run(self):
  3. # Thanks to the question and answers:
  4. # http://stackoverflow.com/questions/4417546/constantly-print-subprocess-output-while-process-is-running
  5. def execute(cmd):
  6. process = subprocess.Popen(cmd)
  7. bar()
  8. stdout_lines = iter(process.stdout.readline, "")
  9. for stdout_line in stdout_lines:
  10. yield stdout_line
  11.  
  12. process.stdout.close()
  13. return_code = process.wait()
  14. if return_code != 0:
  15. raise subprocess.CalledProcessError(return_code, cmd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement