-def do_command (command, filename, escaped=False):
- o = os.popen("%s %s" % (command, filename))
- if escaped:
- return escaped_text(o.read())
- else:
- return formatted_text(o.read())
+def do_command (command, escaped=False):
+ process = daklib.daksubprocess.Popen(command, stdout=subprocess.PIPE)
+ o = process.stdout
+ try:
+ if escaped:
+ return escaped_text(o.read())
+ else:
+ return formatted_text(o.read())
+ finally:
+ process.wait()