Esempio n. 1
0
def __write_result_image(pathbuilder, result_image,
                         outputdir=None, info=None, prefix="merged"):
    if not outputdir:
        outputdir = pathbuilder.create(allow_partial=True)
    elif not os.path.exists(outputdir):
        os.makedirs(outputdir)

    filename = os.path.join(outputdir,
                            prefix + pathbuilder.tagname + ".png")
    LOGGER.debug("Saving merged image for %s to %s", pathbuilder.cid, filename)
    if info:
        result_image = image.add_info(result_image, info)
    result_image.save(open(filename, 'wb'))
Esempio n. 2
0
def __write_merged_image(file1, file2, diff, jobname):
    assert os.path.exists(file1), "file1 doesn't exist at path {}".format(file1)
    assert os.path.exists(file2), "file2 doesn't exist at path {}".format(file2)
    assert isinstance(jobname, basestring), "jobname is not a string!"
    compare_name = __get_compare_name(file1, file2)

    # Generate additional info in output
    mergedimg = image.merge_images(file1, file2)
    info = {"name": compare_name, "diff": diff}
    mergedimg2 = image.add_info(mergedimg, info)

    compare_dir = output.COMPARE_PATH
    build_dir = os.path.join(compare_dir, jobname)
    if not os.path.exists(build_dir):
        os.makedirs(build_dir)
    merged_path = os.path.join(build_dir, compare_name + ".png")
    LOGGER.debug("Writing merged image file at %s", merged_path)
    mergedimg2.save(open(merged_path, 'wb'))
    LOGGER.warning("%s produced diff=%s", compare_name, diff)