def _compare_configs_internal(pathbuilder, configs): """ Compares a given tag for all combinations of the specified list of configs :param pathbuilder: the pathbuilder pointing to the tag to compare :param configs: the list of configs to compare :return: the average diff from image comparison """ total_diff = 0 compare_pb = pathbuilder.clone(build=output.DEFAULT_BUILD_NAME) combo_count = 0 for a, b in itertools.combinations(configs, 2): pba = compare_pb.clone(config=a) pbb = compare_pb.clone(config=b) pba_image = pba.tagimage pbb_image = pbb.tagimage if not os.path.exists(pba_image): LOGGER.error("File not found: %s", pba_image) return settings.ImageErrorLevel.INVALID if not os.path.exists(pbb_image): LOGGER.error("File not found: %s", pbb_image) return settings.ImageErrorLevel.INVALID total_diff += image.compare(pba.tagimage, pbb.tagimage) combo_count += 1 return total_diff / combo_count
def compare_images(file1, file2, jobname): """Compares two image files, returns True if compare took place, False otherwise :param file1: :param file2: :return: """ compare_name = __get_compare_name(file1, file2) if not os.path.exists(file1): LOGGER.debug("SKIPPING %s - %s not found!", compare_name, file1) return None if not os.path.exists(file2): LOGGER.debug("SKIPPING %s - %s not found!", compare_name, file2) return None diff = image.compare(file1, file2) if diff is False: # Unable to produce diff due to errors return False if diff > image.ERROR_THRESHOLD: __write_merged_image(file1, file2, diff, jobname=jobname) return False return True