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

Side by Side Diff: Tools/TestResultServer/handlers/testfilehandler.py

Issue 459263002: Revert "Get rid of testlistjson query parameter." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | Tools/TestResultServer/model/jsonresults.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 PARAM_MASTER = "master" 44 PARAM_MASTER = "master"
45 PARAM_BUILDER = "builder" 45 PARAM_BUILDER = "builder"
46 PARAM_BUILD_NUMBER = "buildnumber" 46 PARAM_BUILD_NUMBER = "buildnumber"
47 PARAM_DIR = "dir" 47 PARAM_DIR = "dir"
48 PARAM_FILE = "file" 48 PARAM_FILE = "file"
49 PARAM_NAME = "name" 49 PARAM_NAME = "name"
50 PARAM_BEFORE = "before" 50 PARAM_BEFORE = "before"
51 PARAM_NUM_FILES = "numfiles" 51 PARAM_NUM_FILES = "numfiles"
52 PARAM_KEY = "key" 52 PARAM_KEY = "key"
53 PARAM_TEST_TYPE = "testtype" 53 PARAM_TEST_TYPE = "testtype"
54 PARAM_TEST_LIST_JSON = "testlistjson"
54 PARAM_CALLBACK = "callback" 55 PARAM_CALLBACK = "callback"
55 56
56 57
57 def _replace_jsonp_callback(json, callback_name): 58 def _replace_jsonp_callback(json, callback_name):
58 if callback_name and re.search(r"^[A-Za-z0-9_]+$", callback_name): 59 if callback_name and re.search(r"^[A-Za-z0-9_]+$", callback_name):
59 if re.search(r"^[A-Za-z0-9_]+[(]", json): 60 if re.search(r"^[A-Za-z0-9_]+[(]", json):
60 return re.sub(r"^[A-Za-z0-9_]+[(]", callback_name + "(", json) 61 return re.sub(r"^[A-Za-z0-9_]+[(]", callback_name + "(", json)
61 return callback_name + "(" + json + ")" 62 return callback_name + "(" + json + ")"
62 63
63 return json 64 return json
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 def _get_file_content_from_key(self, key): 148 def _get_file_content_from_key(self, key):
148 file = db.get(key) 149 file = db.get(key)
149 150
150 if not file: 151 if not file:
151 logging.info("File not found, key %s.", key) 152 logging.info("File not found, key %s.", key)
152 return None 153 return None
153 154
154 file.load_data() 155 file.load_data()
155 return file.data, file.date 156 return file.data, file.date
156 157
158 def _get_test_list_json(self, master, builder, test_type, build_number):
159 """Return json file with test name list only, do not include test
160 results and other non-test-data .
161
162 Args:
163 builder: builder name.
164 test_type: type of test results.
165 """
166
167 json, date = self._get_file_content(master, builder, test_type, build_nu mber, "results.json")
168 if not json:
169 return None
170
171 return JsonResults.get_test_list(builder, json), date
172
157 def _serve_json(self, json, modified_date): 173 def _serve_json(self, json, modified_date):
158 if json: 174 if json:
159 if "If-Modified-Since" in self.request.headers: 175 if "If-Modified-Since" in self.request.headers:
160 old_date = self.request.headers["If-Modified-Since"] 176 old_date = self.request.headers["If-Modified-Since"]
161 if time.strptime(old_date, '%a, %d %b %Y %H:%M:%S %Z') == modifi ed_date.utctimetuple(): 177 if time.strptime(old_date, '%a, %d %b %Y %H:%M:%S %Z') == modifi ed_date.utctimetuple():
162 self.response.set_status(304) 178 self.response.set_status(304)
163 return 179 return
164 180
165 # The appengine datetime objects are naive, so they lack a timezone. 181 # The appengine datetime objects are naive, so they lack a timezone.
166 # In practice, appengine seems to use GMT. 182 # In practice, appengine seems to use GMT.
167 self.response.headers["Last-Modified"] = modified_date.strftime('%a, %d %b %Y %H:%M:%S') + ' GMT' 183 self.response.headers["Last-Modified"] = modified_date.strftime('%a, %d %b %Y %H:%M:%S') + ' GMT'
168 self.response.headers["Content-Type"] = "application/json" 184 self.response.headers["Content-Type"] = "application/json"
169 self.response.headers["Access-Control-Allow-Origin"] = "*" 185 self.response.headers["Access-Control-Allow-Origin"] = "*"
170 self.response.out.write(json) 186 self.response.out.write(json)
171 else: 187 else:
172 self.error(404) 188 self.error(404)
173 189
174 def get(self): 190 def get(self):
175 key = self.request.get(PARAM_KEY) 191 key = self.request.get(PARAM_KEY)
176 master = self.request.get(PARAM_MASTER) 192 master = self.request.get(PARAM_MASTER)
177 builder = self.request.get(PARAM_BUILDER) 193 builder = self.request.get(PARAM_BUILDER)
178 test_type = self.request.get(PARAM_TEST_TYPE) 194 test_type = self.request.get(PARAM_TEST_TYPE)
179 build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None) 195 build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None)
180 name = self.request.get(PARAM_NAME) 196 name = self.request.get(PARAM_NAME)
181 before = self.request.get(PARAM_BEFORE) 197 before = self.request.get(PARAM_BEFORE)
182 num_files = self.request.get(PARAM_NUM_FILES) 198 num_files = self.request.get(PARAM_NUM_FILES)
199 test_list_json = self.request.get(PARAM_TEST_LIST_JSON)
183 callback_name = self.request.get(PARAM_CALLBACK) 200 callback_name = self.request.get(PARAM_CALLBACK)
184 201
185 logging.debug( 202 logging.debug(
186 "Getting files, master %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s.", 203 "Getting files, master %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s.",
187 master, builder, test_type, build_number, name, before) 204 master, builder, test_type, build_number, name, before)
188 205
189 if key: 206 if key:
190 json, date = self._get_file_content_from_key(key) 207 json, date = self._get_file_content_from_key(key)
208 elif test_list_json:
209 json, date = self._get_test_list_json(master, builder, test_type, bu ild_number)
191 elif num_files or not master or not builder or not test_type or (not bui ld_number and not JsonResults.is_aggregate_file(name)) or not name: 210 elif num_files or not master or not builder or not test_type or (not bui ld_number and not JsonResults.is_aggregate_file(name)) or not name:
192 limit = int(num_files) if num_files else 100 211 limit = int(num_files) if num_files else 100
193 self._get_file_list(master, builder, test_type, build_number, name, before, limit, callback_name) 212 self._get_file_list(master, builder, test_type, build_number, name, before, limit, callback_name)
194 return 213 return
195 else: 214 else:
196 # FIXME: Stop using the old master name style after all files have b een updated. 215 # FIXME: Stop using the old master name style after all files have b een updated.
197 master_data = master_config.getMaster(master) 216 master_data = master_config.getMaster(master)
198 if not master_data: 217 if not master_data:
199 master_data = master_config.getMasterByMasterName(master) 218 master_data = master_config.getMasterByMasterName(master)
200 if not master_data: 219 if not master_data:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 316
298 class UploadForm(webapp2.RequestHandler): 317 class UploadForm(webapp2.RequestHandler):
299 """Show a form so user can upload a file.""" 318 """Show a form so user can upload a file."""
300 319
301 def get(self): 320 def get(self):
302 template_values = { 321 template_values = {
303 "upload_url": "/testfile/upload", 322 "upload_url": "/testfile/upload",
304 } 323 }
305 self.response.out.write(template.render("templates/uploadform.html", 324 self.response.out.write(template.render("templates/uploadform.html",
306 template_values)) 325 template_values))
OLDNEW
« no previous file with comments | « no previous file | Tools/TestResultServer/model/jsonresults.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698