+# helper function: execute a process, return output as iterator, throw exception if there was an error
+# you *must* iterate to the end if you use this!
+def processOutputGen(*args):
+ p = subprocess.Popen(args, stdout=subprocess.PIPE)
+ for line in p.stdout:
+ yield line
+ p.wait() # wait for process to exit (it closed stdout, so it can't block anymore)
+ if p.returncode != 0:
+ raise Exception("Error executing "+str(args))
+def processOutputIt(*args):
+ return list(processOutputGen(*args)) # list() iterates over the generator
+