From e6a86b518f7336f2ef49a0fd22ca293b84c7fa00 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Fri, 31 Jan 2014 08:03:58 -0800 Subject: [PATCH] Use the subprocess module, not os.popen2, for Python 3 compatibility. --- python/cumulus/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/cumulus/__init__.py b/python/cumulus/__init__.py index 6e03bd2..c5961c7 100644 --- a/python/cumulus/__init__.py +++ b/python/cumulus/__init__.py @@ -34,6 +34,7 @@ import itertools import os import re import sqlite3 +import subprocess import sys import tarfile import tempfile @@ -379,7 +380,9 @@ class CumulusStore: def filter_data(filehandle, filter_cmd): if filter_cmd is None: return filehandle - (input, output) = os.popen2(filter_cmd) + p = subprocess.Popen(filter_cmd, shell=True, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, close_fds=True) + input, output = p.stdin, p.stdout def copy_thread(src, dst): BLOCK_SIZE = 4096 while True: @@ -388,6 +391,7 @@ class CumulusStore: dst.write(block) src.close() dst.close() + p.wait() _thread.start_new_thread(copy_thread, (filehandle, input)) return output -- 2.20.1