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

Side by Side Diff: Tools/TestResultServer/model/jsonresults.py

Issue 14833004: Revert "Change TestResultServer to use python 2.7." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import json 29 from datetime import datetime
30 from django.utils import simplejson
30 import logging 31 import logging
31 import sys 32 import sys
32 import traceback 33 import traceback
33 34
34 from model.testfile import TestFile 35 from model.testfile import TestFile
35 36
36 JSON_RESULTS_FILE = "results.json" 37 JSON_RESULTS_FILE = "results.json"
37 JSON_RESULTS_FILE_SMALL = "results-small.json" 38 JSON_RESULTS_FILE_SMALL = "results-small.json"
38 JSON_RESULTS_PREFIX = "ADD_RESULTS(" 39 JSON_RESULTS_PREFIX = "ADD_RESULTS("
39 JSON_RESULTS_SUFFIX = ");" 40 JSON_RESULTS_SUFFIX = ");"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 100
100 class JsonResults(object): 101 class JsonResults(object):
101 @classmethod 102 @classmethod
102 def _strip_prefix_suffix(cls, data): 103 def _strip_prefix_suffix(cls, data):
103 # FIXME: Stop stripping jsonp callback once we upload pure json everywhe re. 104 # FIXME: Stop stripping jsonp callback once we upload pure json everywhe re.
104 if data.startswith(JSON_RESULTS_PREFIX) and data.endswith(JSON_RESULTS_S UFFIX): 105 if data.startswith(JSON_RESULTS_PREFIX) and data.endswith(JSON_RESULTS_S UFFIX):
105 return data[len(JSON_RESULTS_PREFIX):len(data) - len(JSON_RESULTS_SU FFIX)] 106 return data[len(JSON_RESULTS_PREFIX):len(data) - len(JSON_RESULTS_SU FFIX)]
106 return data 107 return data
107 108
108 @classmethod 109 @classmethod
109 def _generate_file_data(cls, data, sort_keys=False): 110 def _generate_file_data(cls, json, sort_keys=False):
110 return json.dumps(data, separators=(',', ':'), sort_keys=sort_keys) 111 return simplejson.dumps(json, separators=(',', ':'), sort_keys=sort_keys )
111 112
112 @classmethod 113 @classmethod
113 def _load_json(cls, file_data): 114 def _load_json(cls, file_data):
114 json_results_str = cls._strip_prefix_suffix(file_data) 115 json_results_str = cls._strip_prefix_suffix(file_data)
115 if not json_results_str: 116 if not json_results_str:
116 logging.warning("No json results data.") 117 logging.warning("No json results data.")
117 return None 118 return None
118 119
119 try: 120 try:
120 return json.loads(json_results_str) 121 return simplejson.loads(json_results_str)
121 except: 122 except:
122 logging.debug(json_results_str) 123 logging.debug(json_results_str)
123 logging.error("Failed to load json results: %s", traceback.print_exc eption(*sys.exc_info())) 124 logging.error("Failed to load json results: %s", traceback.print_exc eption(*sys.exc_info()))
124 return None 125 return None
125 126
126 @classmethod 127 @classmethod
127 def _merge_json(cls, aggregated_json, incremental_json, num_runs): 128 def _merge_json(cls, aggregated_json, incremental_json, num_runs):
128 cls._merge_non_test_data(aggregated_json, incremental_json, num_runs) 129 cls._merge_non_test_data(aggregated_json, incremental_json, num_runs)
129 incremental_tests = incremental_json[JSON_RESULTS_TESTS] 130 incremental_tests = incremental_json[JSON_RESULTS_TESTS]
130 if incremental_tests: 131 if incremental_tests:
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 353
353 logging.debug("Checking test results json...") 354 logging.debug("Checking test results json...")
354 if not cls._check_json(builder, json): 355 if not cls._check_json(builder, json):
355 return None 356 return None
356 357
357 test_list_json = {} 358 test_list_json = {}
358 tests = json[builder][JSON_RESULTS_TESTS] 359 tests = json[builder][JSON_RESULTS_TESTS]
359 cls._delete_results_and_times(tests) 360 cls._delete_results_and_times(tests)
360 test_list_json[builder] = {"tests": tests} 361 test_list_json[builder] = {"tests": tests}
361 return cls._generate_file_data(test_list_json) 362 return cls._generate_file_data(test_list_json)
OLDNEW
« no previous file with comments | « Tools/TestResultServer/model/datastorefile.py ('k') | Tools/TestResultServer/model/jsonresults_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698