From b4ebc90dd0b452dfe134efc137de2f62b8ece59e Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Mon, 25 Mar 2013 14:12:12 -0400 Subject: [PATCH] replace subprocess.check_output with Popen magic check_output isn't available in py 2.6... --- Scripts/openchange_cleanup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Scripts/openchange_cleanup.py b/Scripts/openchange_cleanup.py index 92d135a81..9ceeca85a 100755 --- a/Scripts/openchange_cleanup.py +++ b/Scripts/openchange_cleanup.py @@ -223,8 +223,13 @@ def getOCSFolderInfoURL(): if os.path.exists(f): # FIXME: this is ugly, we should have a python plist parser # plistlib only supports XML plists. - pipeline = """sogo-tool dump-defaults -f %s | grep -w OCSFolderInfoURL | awk -F\\" '{print $2}'""" % f - tmp = subprocess.check_output(pipeline, shell=True) + # the following magic replaces this shell pipeline: + # sogo-tool dump-defaults -f %s | awk -F\\" '/ OCSFolderInfoURL =/ {print $2}' + p1 = subprocess.Popen(["sogo-tool", "dump-defaults", "-f", f], stdout=subprocess.PIPE) + p2 = subprocess.Popen(["awk", "-F\"", "/ OCSFolderInfoURL =/ {print $2}"], stdin=p1.stdout, stdout=subprocess.PIPE) + p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. + tmp = p2.communicate()[0] + if tmp: OCSFolderInfoURL = tmp return OCSFolderInfoURL