+def write_pipe (c, str):
+ if not silent:
+ sys.stderr.write ('writing pipe: %s\n' % c)
+
+ ## todo: check return status
+ pipe = os.popen (c, 'w')
+ val = pipe.write(str)
+ if pipe.close ():
+ sys.stderr.write ('Command failed')
+ sys.exit (1)
+
+ return val
+
+def read_pipe (c):
+ sys.stderr.write ('reading pipe: %s\n' % c)
+ ## todo: check return status
+ pipe = os.popen (c, 'rb')
+ val = pipe.read()
+ if pipe.close ():
+ sys.stderr.write ('Command failed')
+ sys.exit (1)
+
+ return val
+
+
+def read_pipe_lines (c):
+ sys.stderr.write ('reading pipe: %s\n' % c)
+ ## todo: check return status
+ pipe = os.popen (c, 'rb')
+ val = pipe.readlines()
+ if pipe.close ():
+ sys.stderr.write ('Command failed')
+ sys.exit (1)
+
+ return val