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

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

Issue 463683002: 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"
55 PARAM_CALLBACK = "callback" 54 PARAM_CALLBACK = "callback"
56 55
57 56
58 def _replace_jsonp_callback(json, callback_name): 57 def _replace_jsonp_callback(json, callback_name):
59 if callback_name and re.search(r"^[A-Za-z0-9_]+$", callback_name): 58 if callback_name and re.search(r"^[A-Za-z0-9_]+$", callback_name):
60 if re.search(r"^[A-Za-z0-9_]+[(]", json): 59 if re.search(r"^[A-Za-z0-9_]+[(]", json):
61 return re.sub(r"^[A-Za-z0-9_]+[(]", callback_name + "(", json) 60 return re.sub(r"^[A-Za-z0-9_]+[(]", callback_name + "(", json)
62 return callback_name + "(" + json + ")" 61 return callback_name + "(" + json + ")"
63 62
64 return json 63 return json
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 def _get_file_content_from_key(self, key): 147 def _get_file_content_from_key(self, key):
149 file = db.get(key) 148 file = db.get(key)
150 149
151 if not file: 150 if not file:
152 logging.info("File not found, key %s.", key) 151 logging.info("File not found, key %s.", key)
153 return None 152 return None
154 153
155 file.load_data() 154 file.load_data()
156 return file.data, file.date 155 return file.data, file.date
157 156
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
173 def _serve_json(self, json, modified_date): 157 def _serve_json(self, json, modified_date):
174 if json: 158 if json:
175 if "If-Modified-Since" in self.request.headers: 159 if "If-Modified-Since" in self.request.headers:
176 old_date = self.request.headers["If-Modified-Since"] 160 old_date = self.request.headers["If-Modified-Since"]
177 if time.strptime(old_date, '%a, %d %b %Y %H:%M:%S %Z') == modifi ed_date.utctimetuple(): 161 if time.strptime(old_date, '%a, %d %b %Y %H:%M:%S %Z') == modifi ed_date.utctimetuple():
178 self.response.set_status(304) 162 self.response.set_status(304)
179 return 163 return
180 164
181 # The appengine datetime objects are naive, so they lack a timezone. 165 # The appengine datetime objects are naive, so they lack a timezone.
182 # In practice, appengine seems to use GMT. 166 # In practice, appengine seems to use GMT.
183 self.response.headers["Last-Modified"] = modified_date.strftime('%a, %d %b %Y %H:%M:%S') + ' GMT' 167 self.response.headers["Last-Modified"] = modified_date.strftime('%a, %d %b %Y %H:%M:%S') + ' GMT'
184 self.response.headers["Content-Type"] = "application/json" 168 self.response.headers["Content-Type"] = "application/json"
185 self.response.headers["Access-Control-Allow-Origin"] = "*" 169 self.response.headers["Access-Control-Allow-Origin"] = "*"
186 self.response.out.write(json) 170 self.response.out.write(json)
187 else: 171 else:
188 self.error(404) 172 self.error(404)
189 173
190 def get(self): 174 def get(self):
191 key = self.request.get(PARAM_KEY) 175 key = self.request.get(PARAM_KEY)
192 master = self.request.get(PARAM_MASTER) 176 master = self.request.get(PARAM_MASTER)
193 builder = self.request.get(PARAM_BUILDER) 177 builder = self.request.get(PARAM_BUILDER)
194 test_type = self.request.get(PARAM_TEST_TYPE) 178 test_type = self.request.get(PARAM_TEST_TYPE)
195 build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None) 179 build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None)
196 name = self.request.get(PARAM_NAME) 180 name = self.request.get(PARAM_NAME)
197 before = self.request.get(PARAM_BEFORE) 181 before = self.request.get(PARAM_BEFORE)
198 num_files = self.request.get(PARAM_NUM_FILES) 182 num_files = self.request.get(PARAM_NUM_FILES)
199 test_list_json = self.request.get(PARAM_TEST_LIST_JSON)
200 callback_name = self.request.get(PARAM_CALLBACK) 183 callback_name = self.request.get(PARAM_CALLBACK)
201 184
202 logging.debug( 185 logging.debug(
203 "Getting files, master %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s.", 186 "Getting files, master %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s.",
204 master, builder, test_type, build_number, name, before) 187 master, builder, test_type, build_number, name, before)
205 188
206 if key: 189 if key:
207 json, date = self._get_file_content_from_key(key) 190 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)
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: 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:
211 limit = int(num_files) if num_files else 100 192 limit = int(num_files) if num_files else 100
212 self._get_file_list(master, builder, test_type, build_number, name, before, limit, callback_name) 193 self._get_file_list(master, builder, test_type, build_number, name, before, limit, callback_name)
213 return 194 return
214 else: 195 else:
215 # FIXME: Stop using the old master name style after all files have b een updated. 196 # FIXME: Stop using the old master name style after all files have b een updated.
216 master_data = master_config.getMaster(master) 197 master_data = master_config.getMaster(master)
217 if not master_data: 198 if not master_data:
218 master_data = master_config.getMasterByMasterName(master) 199 master_data = master_config.getMasterByMasterName(master)
219 if not master_data: 200 if not master_data:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 297
317 class UploadForm(webapp2.RequestHandler): 298 class UploadForm(webapp2.RequestHandler):
318 """Show a form so user can upload a file.""" 299 """Show a form so user can upload a file."""
319 300
320 def get(self): 301 def get(self):
321 template_values = { 302 template_values = {
322 "upload_url": "/testfile/upload", 303 "upload_url": "/testfile/upload",
323 } 304 }
324 self.response.out.write(template.render("templates/uploadform.html", 305 self.response.out.write(template.render("templates/uploadform.html",
325 template_values)) 306 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