Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Unified Diff: gm/rebaseline_server/imagediffdb.py

Issue 117823008: Adding additional optional parameters to imagediffdb to make calling from Cluster Telemetry possibl… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/rebaseline_server/imagediffdb.py
===================================================================
--- gm/rebaseline_server/imagediffdb.py (revision 12765)
+++ gm/rebaseline_server/imagediffdb.py (working copy)
@@ -20,9 +20,9 @@
raise ImportError('Requires PIL to be installed; see '
+ 'http://www.pythonware.com/products/pil/')
-IMAGE_SUFFIX = '.png'
+DEFAULT_IMAGE_SUFFIX = '.png'
+DEFAULT_IMAGES_SUBDIR = 'images'
-IMAGES_SUBDIR = 'images'
DIFFS_SUBDIR = 'diffs'
WHITEDIFFS_SUBDIR = 'whitediffs'
@@ -34,7 +34,10 @@
def __init__(self, storage_root,
expected_image_url, expected_image_locator,
- actual_image_url, actual_image_locator):
+ actual_image_url, actual_image_locator,
+ expected_images_subdir=DEFAULT_IMAGES_SUBDIR,
+ actual_images_subdir=DEFAULT_IMAGES_SUBDIR,
+ image_suffix=DEFAULT_IMAGE_SUFFIX):
"""Download this pair of images (unless we already have them on local disk),
and prepare a DiffRecord for them.
@@ -54,15 +57,21 @@
actual_image_locator: a unique ID string under which we will store the
actual image within storage_root (probably including a checksum to
guarantee uniqueness)
+ expected_images_subdir: the subdirectory expected images are stored in.
+ actual_images_subdir: the subdirectory actual images are stored in.
+ image_suffix: the suffix of images.
"""
# Download the expected/actual images, if we don't have them already.
+ # TODO(rmistry): Add a parameter that makes _download_and_open_image raise
+ # an exception if images are not found locally (instead of trying to
+ # download them).
expected_image = _download_and_open_image(
- os.path.join(storage_root, IMAGES_SUBDIR,
- str(expected_image_locator) + IMAGE_SUFFIX),
+ os.path.join(storage_root, expected_images_subdir,
+ str(expected_image_locator) + image_suffix),
expected_image_url)
actual_image = _download_and_open_image(
- os.path.join(storage_root, IMAGES_SUBDIR,
- str(actual_image_locator) + IMAGE_SUFFIX),
+ os.path.join(storage_root, actual_images_subdir,
+ str(actual_image_locator) + image_suffix),
actual_image_url)
# Generate the diff image (absolute diff at each pixel) and
@@ -92,7 +101,7 @@
diff_image_locator = _get_difference_locator(
expected_image_locator=expected_image_locator,
actual_image_locator=actual_image_locator)
- basename = str(diff_image_locator) + IMAGE_SUFFIX
+ basename = str(diff_image_locator) + image_suffix
_save_image(diff_image, os.path.join(
storage_root, DIFFS_SUBDIR, basename))
_save_image(whitediff_image, os.path.join(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698