use subprocess instead of os.popen to run diff stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Fri, 12 Feb 2010 12:55:49 +0100
branchstable
changeset 4554 2279ba039494
parent 4524 2eb36514ad6d
child 4555 8968c50818db
use subprocess instead of os.popen to run diff this avoids argument quoting issues (spaces in path, etc)
toolsutils.py
--- a/toolsutils.py	Tue Feb 09 08:15:20 2010 +0100
+++ b/toolsutils.py	Fri Feb 12 12:55:49 2010 +0100
@@ -10,6 +10,7 @@
 # XXX move most of this in logilab.common (shellutils ?)
 
 import os, sys
+import subprocess
 from os import listdir, makedirs, environ, chmod, walk, remove
 from os.path import exists, join, abspath, normpath
 
@@ -72,8 +73,8 @@
     user decision
     """
     import shutil
-    p_output = os.popen('diff -u %s %s' % (appl_file, ref_file), 'r')
-    diffs = p_output.read()
+    pipe = subprocess.Popen(['diff', '-u', appl_file, ref_file], stdout=subprocess.PIPE)
+    diffs = pipe.stdout.read()
     if diffs:
         if askconfirm:
             print