标签:配置文件 python except error return
通过html来比较nginx配置文件和备份的ngixn不同
#!/usr/bin/env python
import difflib
import sys
try:
textfile1 = sys.argv[1]
textfile2 = sys.argv[2]
except Exception,e:
print "error:"+str(e)
print "Usage: diff_nginx.py filename1 filename2"
sys.exit()
def readline(filename):
try:
fileHandle = open(filename, ‘rb‘)
text = fileHandle.read().splitlines()
fileHandle.close()
return text
except IOError as error:
print (‘Read file error:‘ +str(error))
sys.exit()
if textfile1 == "" or textfile2 == "":
print "Usage: diff_nginx.py filename1 filename2"
sys.exit()
text1_lines = readline(textfile1)
text2_lines = readline(textfile2)
d = difflib.HtmlDiff()
print d.make_file(text1_lines, text2_lines)
标签:配置文件 python except error return
原文地址:http://yzg784534398.blog.51cto.com/9719002/1684030