toolsutils.py
changeset 4587 70d47389630c
parent 4556 43c14e0e8972
child 4721 8f63691ccb7f
equal deleted inserted replaced
4567:bf3453789887 4587:70d47389630c
     8 __docformat__ = "restructuredtext en"
     8 __docformat__ = "restructuredtext en"
     9 
     9 
    10 # XXX move most of this in logilab.common (shellutils ?)
    10 # XXX move most of this in logilab.common (shellutils ?)
    11 
    11 
    12 import os, sys
    12 import os, sys
       
    13 import subprocess
    13 from os import listdir, makedirs, environ, chmod, walk, remove
    14 from os import listdir, makedirs, environ, chmod, walk, remove
    14 from os.path import exists, join, abspath, normpath
    15 from os.path import exists, join, abspath, normpath
    15 
    16 
    16 try:
    17 try:
    17     from os import symlink
    18     from os import symlink
    73 def show_diffs(appl_file, ref_file, askconfirm=True):
    74 def show_diffs(appl_file, ref_file, askconfirm=True):
    74     """interactivly replace the old file with the new file according to
    75     """interactivly replace the old file with the new file according to
    75     user decision
    76     user decision
    76     """
    77     """
    77     import shutil
    78     import shutil
    78     p_output = os.popen('diff -u %s %s' % (appl_file, ref_file), 'r')
    79     pipe = subprocess.Popen(['diff', '-u', appl_file, ref_file], stdout=subprocess.PIPE)
    79     diffs = p_output.read()
    80     diffs = pipe.stdout.read()
    80     if diffs:
    81     if diffs:
    81         if askconfirm:
    82         if askconfirm:
    82             print
    83             print
    83             print diffs
    84             print diffs
    84             action = ASK.ask('Replace ?', ('N','y','q'), 'N')
    85             action = ASK.ask('Replace ?', ('N','y','q'), 'N')