#!/usr/bin/python #coding=utf8 """ # Author: xiaoyafei # Created Time : 2018-04-04 17:14:20 # File Name: check_Nginx_conf.py # Description: """ import... ...
#!/usr/bin/python #coding=utf8 """ # Author: xiaoyafei # Created Time : 2018-04-04 17:14:20 # File Name: check_Nginx_conf.py # Description: """ import difflib import sys try: textfile1 = sys.argv[1] textfile2 = sys.argv[2] except Exception,e: print "Error:"+str(e) print "Usage: check_Nginx_conf.py filename1 filename2" sys.exit() def readfile(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: check_Nginx_conf.py filename1 filename2" text1_lines = readfile(textfile1) text2_lines = readfile(textfile2) d = difflib.HtmlDiff() print d.make_file(text1_lines,text2_lines)