use of subprocess module inside generator
Peter
p-santoro at sbcglobal.net
Wed May 13 19:54:43 EDT 2015
Gary,
Thank you for the response. I made a small typo in my original post,
which you correctly picked up. My original generator actually did not
have the stdout parameter (see below). Only the new generator has this
parameter, as it's now being passed into the generator from the caller's
execution of subprocess.check_output.
def _raw_data(cl, *, opath=None, timeout=timeout):
stdout = subprocess.check_output(cl, universal_newlines=True,
timeout=timeout)
if opath is None:
for line in stdout.splitlines():
yield line.strip()
else:
with open(opath) as f:
for line in f:
yield line.strip()
Peter
More information about the Python-list
mailing list