Created
March 3, 2010 18:24
-
-
Save dakrone/320839 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from os.path import join, getsize, walk | |
fileNames1 = [] | |
fileNames2 = [] | |
fullNames1 = [] | |
fullNames2 = [] | |
returnValue = 0 | |
def buildNames1(d): | |
for filename in os.listdir(d): | |
if os.path.isfile(join(d,filename)): | |
fileNames1.append(filename) | |
fullNames1.append(join(d,filename)) | |
else: | |
buildNames1(join(d,filename)) | |
def buildNames2(d): | |
for filename in os.listdir(d): | |
if os.path.isfile(join(d,filename)): | |
fileNames2.append(filename) | |
fullNames2.append(join(d,filename)) | |
else: | |
buildNames2(join(d,filename)) | |
#for root, dirs, files in os.path.walk("$(expectedFolder)"): | |
# for name in files: | |
# #print join(root,name) | |
# fileNames1.append(name) | |
# fullNames1.append(join(root,name)) | |
buildNames1("$(expectedFolder)") | |
print fileNames1 | |
#for root, dirs, files in os.path.walk("$(actualFolder)"): | |
# for name in files: | |
# #print join(root,name) | |
# fileNames2.append(name) | |
# fullNames2.append(join(root,name)) | |
buildNames2("$(actualFolder)") | |
print fileNames2 | |
if fileNames1 != fileNames2: | |
print "Directories Different" | |
returnValue = -1 | |
else: | |
i = 0 | |
while i < len(fileNames1): | |
try: | |
print fullNames1[i] | |
f = open(fullNames1[i], 'r') | |
g = open(fullNames2[i], 'r') | |
line1 = "a" | |
line2 = "a" | |
while (line1 != '' and line2 != ''): | |
line1 = f.readline() | |
line2 = g.readline() | |
if line1 != line2: | |
print "Files Different" | |
returnValue = -1 | |
rc.setGlobal("returnValue","-1") | |
i = i + 1 | |
finally: | |
f.close() | |
g.close() | |
print "Files are the same" | |
#f.close() | |
#g.close() | |
rc.setGlobal("returnValue","0") | |
rc.check(0==returnValue,"test message",rc.EXCEPTION) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment