OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 ''' | 3 ''' |
4 Copyright 2012 Google Inc. | 4 Copyright 2012 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 ''' | 8 ''' |
9 | 9 |
10 ''' | 10 ''' |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 'Test-Android-NexusS-SGX540-Arm7-Release', | 64 'Test-Android-NexusS-SGX540-Arm7-Release', |
65 'base-android-xoom': | 65 'base-android-xoom': |
66 'Test-Android-Xoom-Tegra2-Arm7-Release', | 66 'Test-Android-Xoom-Tegra2-Arm7-Release', |
67 'base-android-nexus-10': | 67 'base-android-nexus-10': |
68 'Test-Android-Nexus10-MaliT604-Arm7-Release', | 68 'Test-Android-Nexus10-MaliT604-Arm7-Release', |
69 'base-android-nexus-4': | 69 'base-android-nexus-4': |
70 'Test-Android-Nexus4-Adreno320-Arm7-Release', | 70 'Test-Android-Nexus4-Adreno320-Arm7-Release', |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 class CommandFailedException(Exception): | 74 class _InternalException(Exception): |
75 pass | 75 pass |
76 | 76 |
77 # Object that rebaselines a JSON expectations file (not individual image files). | 77 # Object that rebaselines a JSON expectations file (not individual image files). |
78 class JsonRebaseliner(object): | 78 class JsonRebaseliner(object): |
79 | 79 |
80 # params: | 80 # params: |
81 # expectations_root: root directory of all expectations JSON files | 81 # expectations_root: root directory of all expectations JSON files |
82 # expectations_filename: filename (under expectations_root) of JSON | 82 # expectations_filename: filename (under expectations_root) of JSON |
83 # expectations file; typically | 83 # expectations file; typically |
84 # "expected-results.json" | 84 # "expected-results.json" |
(...skipping 14 matching lines...) Expand all Loading... |
99 self._tests = tests | 99 self._tests = tests |
100 self._configs = configs | 100 self._configs = configs |
101 self._actuals_base_url = actuals_base_url | 101 self._actuals_base_url = actuals_base_url |
102 self._actuals_filename = actuals_filename | 102 self._actuals_filename = actuals_filename |
103 self._add_new = add_new | 103 self._add_new = add_new |
104 self._testname_pattern = re.compile('(\S+)_(\S+).png') | 104 self._testname_pattern = re.compile('(\S+)_(\S+).png') |
105 | 105 |
106 # Returns the full contents of filepath, as a single string. | 106 # Returns the full contents of filepath, as a single string. |
107 # If filepath looks like a URL, try to read it that way instead of as | 107 # If filepath looks like a URL, try to read it that way instead of as |
108 # a path on local storage. | 108 # a path on local storage. |
| 109 # |
| 110 # Raises _InternalException if there is a problem. |
109 def _GetFileContents(self, filepath): | 111 def _GetFileContents(self, filepath): |
110 if filepath.startswith('http:') or filepath.startswith('https:'): | 112 if filepath.startswith('http:') or filepath.startswith('https:'): |
111 return urllib2.urlopen(filepath).read() | 113 try: |
| 114 return urllib2.urlopen(filepath).read() |
| 115 except urllib2.HTTPError as e: |
| 116 raise _InternalException('unable to read URL %s: %s' % ( |
| 117 filepath, e)) |
112 else: | 118 else: |
113 return open(filepath, 'r').read() | 119 return open(filepath, 'r').read() |
114 | 120 |
115 # Returns a dictionary of actual results from actual-results.json file. | 121 # Returns a dictionary of actual results from actual-results.json file. |
116 # | 122 # |
117 # The dictionary returned has this format: | 123 # The dictionary returned has this format: |
118 # { | 124 # { |
119 # u'imageblur_565.png': [u'bitmap-64bitMD5', 3359963596899141322], | 125 # u'imageblur_565.png': [u'bitmap-64bitMD5', 3359963596899141322], |
120 # u'imageblur_8888.png': [u'bitmap-64bitMD5', 4217923806027861152], | 126 # u'imageblur_8888.png': [u'bitmap-64bitMD5', 4217923806027861152], |
121 # u'shadertext3_8888.png': [u'bitmap-64bitMD5', 3713708307125704716] | 127 # u'shadertext3_8888.png': [u'bitmap-64bitMD5', 3713708307125704716] |
122 # } | 128 # } |
123 # | 129 # |
124 # If the JSON actual result summary file cannot be loaded, raise an | 130 # If the JSON actual result summary file cannot be loaded, logs a warning |
125 # exception. | 131 # message and returns None. |
| 132 # If the JSON actual result summary file can be loaded, but we have |
| 133 # trouble parsing it, raises an Exception. |
126 # | 134 # |
127 # params: | 135 # params: |
128 # json_url: URL pointing to a JSON actual result summary file | 136 # json_url: URL pointing to a JSON actual result summary file |
129 # sections: a list of section names to include in the results, e.g. | 137 # sections: a list of section names to include in the results, e.g. |
130 # [gm_json.JSONKEY_ACTUALRESULTS_FAILED, | 138 # [gm_json.JSONKEY_ACTUALRESULTS_FAILED, |
131 # gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON] ; | 139 # gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON] ; |
132 # if None, then include ALL sections. | 140 # if None, then include ALL sections. |
133 def _GetActualResults(self, json_url, sections=None): | 141 def _GetActualResults(self, json_url, sections=None): |
134 json_contents = self._GetFileContents(json_url) | 142 try: |
| 143 json_contents = self._GetFileContents(json_url) |
| 144 except _InternalException: |
| 145 print >> sys.stderr, ( |
| 146 'could not read json_url %s ; skipping this platform.' % |
| 147 json_url) |
| 148 return None |
135 json_dict = gm_json.LoadFromString(json_contents) | 149 json_dict = gm_json.LoadFromString(json_contents) |
136 results_to_return = {} | 150 results_to_return = {} |
137 actual_results = json_dict[gm_json.JSONKEY_ACTUALRESULTS] | 151 actual_results = json_dict[gm_json.JSONKEY_ACTUALRESULTS] |
138 if not sections: | 152 if not sections: |
139 sections = actual_results.keys() | 153 sections = actual_results.keys() |
140 for section in sections: | 154 for section in sections: |
141 section_results = actual_results[section] | 155 section_results = actual_results[section] |
142 if section_results: | 156 if section_results: |
143 results_to_return.update(section_results) | 157 results_to_return.update(section_results) |
144 return results_to_return | 158 return results_to_return |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 dry_run=args.dry_run, | 297 dry_run=args.dry_run, |
284 json_base_url=args.actuals_base_url, | 298 json_base_url=args.actuals_base_url, |
285 json_filename=args.actuals_filename, | 299 json_filename=args.actuals_filename, |
286 add_new=args.add_new, | 300 add_new=args.add_new, |
287 missing_json_is_fatal=missing_json_is_fatal) | 301 missing_json_is_fatal=missing_json_is_fatal) |
288 try: | 302 try: |
289 rebaseliner.RebaselineSubdir(subdir=subdir, builder=builder) | 303 rebaseliner.RebaselineSubdir(subdir=subdir, builder=builder) |
290 except BaseException as e: | 304 except BaseException as e: |
291 print >> sys.stderr, e | 305 print >> sys.stderr, e |
292 sys.exit(1) | 306 sys.exit(1) |
OLD | NEW |