b2cf390e98648bbb8f4e919a0ad6d923aea3a24f gperez2 Mon Jul 18 15:17:48 2022 -0700 Code review edits, refs #29768 diff --git src/utils/qa/imageComp.py src/utils/qa/imageComp.py index 6b46a5b..8297ba6 100755 --- src/utils/qa/imageComp.py +++ src/utils/qa/imageComp.py @@ -82,47 +82,51 @@ elif os.path.getsize(serverDir1+"/"+image) == 0: emptyFiles+=1 else: imagesCompared+=1 previousImage = Image.open(serverDir1+"/"+image).convert('RGB') newImage = Image.open(serverDir2+"/"+image).convert('RGB') diff = ImageChops.difference(previousImage, newImage) if diff.getbbox(): differentImages+=1 diff.save(diffImagesDir+image) diffImages.append(image) else: noDiffImages.append(image) return(emptyFiles,imagesCompared,differentImages,diffImages,noDiffImages) -def reportOutput(emptyFiles,imagesCompared,differentImages,diffImages,noDiffImages,diffImagesDir,publicHtmlDirToSave,publicHtmlDirToView,serverUrl1,sessionUser1,sessionName1,serverUrl2,sessionUser2,sessionName2): +def reportOutput(emptyFiles,imagesCompared,differentImages,diffImages,noDiffImages,\ + diffImagesDir,publicHtmlDirToSave,publicHtmlDirToView,serverUrl1,\ + sessionUser1,sessionName1,serverUrl2,sessionUser2,sessionName2): '''Report findings, if differences found create symlinks to public html''' if noDiffImages != []: print("No differences seen in the following session(s):") for image in noDiffImages: print(image) if diffImages != []: print("\nDifferences were observed in the following session(s):") for image in diffImages: print(image) run(["ln", "-sf", diffImagesDir+image, publicHtmlDirToSave+image]) print("Link: "+publicHtmlDirToView+image) - print("session 1: "+serverUrl1+"/cgi-bin/hgTracks?hgS_doOtherUser=submit&hgS_otherUserName="+sessionUser1+"&hgS_otherUserSessionName="+sessionName1) - print("session 1: "+serverUrl2+"/cgi-bin/hgTracks?hgS_doOtherUser=submit&hgS_otherUserName="+sessionUser2+"&hgS_otherUserSessionName="+sessionName2) - print("\nNumber of empty session files created: "+str(emptyFiles)) - print("Total number of images compared: "+str(imagesCompared)) - print("Different images found: "+str(differentImages)) + print("session 1: %s/cgi-bin/hgTracks?hgS_doOtherUser=submit&hgS_otherUserName=%s&hgS_otherUserSessionName=%s" + %(serverUrl1,sessionUser1,sessionName1)) + print("session 1: %s/cgi-bin/hgTracks?hgS_doOtherUser=submit&hgS_otherUserName=%s&hgS_otherUserSessionName=%s" + %(serverUrl2,sessionUser2,sessionName2)) + print("\nNumber of empty session files created: %s" % emptyFiles) + print("Total number of images compared: %s" % imagesCompared) + print("Different images found: %s" % differentImages) ########### #To be used when extracting all session data #sessionData = run(["hgsql", "-e", "select userName,sessionName from namedSessionDb", "hgcentraltest"], stdout=subprocess.PIPE) ########## def main(): user = getpass.getuser() #Define cars serverUrl1 = "https://hgwdev.gi.ucsc.edu/" serverUrl2 = "https://hgwbeta.soe.ucsc.edu/" sessionUser1 = "lou" sessionUser2 = "lou" sessionName1 = "imageCompCron1.2" sessionName2 = "imageCompCron1.2" @@ -130,18 +134,20 @@ serverDir2 = "/hive/users/"+user+"/imageTest/cronImages/server2Images" diffImagesDir = "/hive/users/"+user+"/imageTest/cronImages/diffImages/" publicHtmlDirToSave = "/cluster/home/"+user+"/public_html/images/" publicHtmlDirToView = "https://hgwdev.gi.ucsc.edu/~"+user+"/images/" #Create first set of image file(s) populateServerDir1(sessionUser1,sessionName1,serverDir1,serverUrl1) #Create second set of image file(s) imageFiles = [] imageFiles.append(createImageFromSession(sessionUser2,sessionName2,serverDir2,serverUrl2)) #Compare images emptyFiles,imagesCompared,differentImages,diffImages,noDiffImages = imageCompare(imageFiles,serverDir2,serverDir1,diffImagesDir) #Report findings if diffImages == []: #Check if there is anything to report - that way cron does not output pass else: - reportOutput(emptyFiles,imagesCompared,differentImages,diffImages,noDiffImages,diffImagesDir,publicHtmlDirToSave,publicHtmlDirToView,serverUrl1,sessionUser1,sessionName1,serverUrl2,sessionUser2,sessionName2) + reportOutput(emptyFiles,imagesCompared,differentImages,diffImages,noDiffImages,\ + diffImagesDir,publicHtmlDirToSave,publicHtmlDirToView,serverUrl1,\ + sessionUser1,sessionName1,serverUrl2,sessionUser2,sessionName2) main()