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

Unified Diff: tools/verify_images_for_gm_results.py

Issue 18743006: Add script to verify that image files exist for every actual_result checksum (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months 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: tools/verify_images_for_gm_results.py
===================================================================
--- tools/verify_images_for_gm_results.py (revision 0)
+++ tools/verify_images_for_gm_results.py (revision 0)
@@ -0,0 +1,110 @@
+#!/usr/bin/python
+
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+""" find_missing_images: Look through skia-autogen, searching for all checksums
epoger 2013/07/10 19:30:44 Delete no-longer-accurate script name
borenet 2013/07/10 20:36:45 Done.
+which should have corresponding files in Google Storage, and verify that those
+files exist. """
+
+
+import json
+import posixpath
+import subprocess
+import sys
+
+
+AUTOGEN_URL = 'http://skia-autogen.googlecode.com/svn/gm-actual'
epoger 2013/07/10 19:30:44 optional: use argparse with defaults (like https:/
borenet 2013/07/10 20:36:45 Mind if I save this for the future? I'd like to j
epoger 2013/07/11 14:14:25 No problem.
+GS_URL = 'gs://chromium-skia-gm/gm/'
+
+
+def FileNameToResultType(filename):
epoger 2013/07/10 19:30:44 please add a brief description of each function
borenet 2013/07/10 20:36:45 Done.
+ result = filename
+ for suffix in ['.png', '_8888', '_565', '_gpu', '_gpudebug', '_msaa4']:
epoger 2013/07/10 19:30:44 I don't understand why we need this list of suffix
borenet 2013/07/10 20:36:45 Done.
+ if result.endswith(suffix):
+ result = result[:len(result) - len(suffix)]
+ return result
+
+
+def FindChecksumsInJSON(json_file):
+ print 'svn cat %s' % json_file
+ output = subprocess.check_output(['svn', 'cat', json_file])
+ json_content = json.loads(output)
+ checksums = []
+ for dict_type in ['actual-results']:
+ for result_type in json_content[dict_type]:
+ if json_content[dict_type][result_type]:
+ for result in json_content[dict_type][result_type].keys():
+ hash_type, hash = json_content[dict_type][result_type][result]
+ checksum = posixpath.join(hash_type,
+ FileNameToResultType(result),
+ str(hash))
+ checksums.append(checksum)
+ return checksums
+
+
+def _FindJSONFiles(url, json_files):
+ proc = subprocess.Popen(['svn', 'ls', url], stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ if proc.wait() != 0:
+ raise Exception('Failed to list svn directory.')
+ output = proc.communicate()[0].splitlines()
+ subdirs = []
+ for item in output:
+ if item.endswith(posixpath.sep):
+ subdirs.append(item)
+ elif item.endswith('.json'):
+ json_files.append(posixpath.join(url, item))
+ else:
+ print 'Warning: ignoring %s' % posixpath.join(url, item)
+ for subdir in subdirs:
+ _FindJSONFiles(posixpath.join(url, subdir), json_files)
+
+
+def FindJSONFiles(url):
+ print 'Searching for json files in %s' % url
+ json_files = []
+ _FindJSONFiles(url, json_files)
+ return json_files
+
+
+def FindChecksums(url):
+ checksums = set()
+ for json_file in FindJSONFiles(url):
+ print 'Looking for checksums in %s' % json_file
+ checksums.update(FindChecksumsInJSON(json_file))
+ return checksums
+
+
+def VerifyChecksum(checksum):
+ image_url = posixpath.join(GS_URL, checksum + '.png')
+ proc = subprocess.Popen(['gsutil', 'ls', image_url], stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ if proc.wait() != 0:
+ return False
+ return True
+
+
+def VerifyChecksums(checksums):
+ print 'Verifying that images exist for checksums...'
+ missing = []
+ for checksum in checksums:
+ if not VerifyChecksum(checksum):
+ print 'Missing: %s' % checksum
+ missing.append(checksum)
+ return missing
+
+
+def Main():
+ checksums = FindChecksums(AUTOGEN_URL)
+ missing = VerifyChecksums(checksums)
+ if missing:
+ print 'Missing files:'
epoger 2013/07/10 19:30:44 please print the number of missing files
borenet 2013/07/10 20:36:45 Done.
+ print '\n'.join(missing)
+ return 1
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
« 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