Making generate_diff_insert python2.7 compatible.

This commit is contained in:
C Nelson 2012-04-06 13:12:30 -05:00
parent 1d17d3e810
commit bd06a22fb8

View File

@ -5835,14 +5835,17 @@ def generate_diff_insert(line_number, newline, debug=False):
newfile_fh.write(newfile)
newfile_fh.close()
try:
from subprocess import CalledProcessError
except ImportError:
CalledProcessError = None
try:
diffcontent = subprocess.check_output("diff -u ../main.asm " + newfile_filename, shell=True)
except AttributeError, exc:
except (AttributeError, CalledProcessError):
p = subprocess.Popen(["diff", "-u", "../main.asm", newfile_filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
diffcontent = out
except Exception, exc:
raise exc
os.system("rm " + original_filename)
os.system("rm " + newfile_filename)