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

Side by Side Diff: Tools/RebaselineLogServer/main.py

Issue 304303003: Make the rebaseline log server resilient to large logs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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/RebaselineLogServer/main_unittest.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) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 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 14 matching lines...) Expand all
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 datetime 29 import datetime
30 import logging 30 import logging
31 import webapp2 31 import webapp2
32 32
33 from google.appengine.ext import ndb 33 from google.appengine.ext import ndb
34 from google.appengine.ext.webapp import template 34 from google.appengine.ext.webapp import template
35 from google.appengine.ext.db import BadRequestError
35 36
36 # A simple log server for rebaseline-o-matic. 37 # A simple log server for rebaseline-o-matic.
37 # 38 #
38 # Accepts updates to the same log entry and shows a simple status page. 39 # Accepts updates to the same log entry and shows a simple status page.
39 # Has a special state for the case where there are no NeedsRebaseline 40 # Has a special state for the case where there are no NeedsRebaseline
40 # lines in TestExpectations to avoid cluttering the log with useless 41 # lines in TestExpectations to avoid cluttering the log with useless
41 # entries every 30 seconds. 42 # entries every 30 seconds.
42 # 43 #
43 # Other than that, new updatelog calls append to the most recent log 44 # Other than that, new updatelog calls append to the most recent log
44 # entry until they have the newentry parameter, in which case, it 45 # entry until they have the newentry parameter, in which case, it
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 elif log_entry.is_no_needs_rebaseline: 94 elif log_entry.is_no_needs_rebaseline:
94 out = "Previous entry was a no need rebaseline log. Writing a new log." 95 out = "Previous entry was a no need rebaseline log. Writing a new log."
95 new_entry = True 96 new_entry = True
96 else: 97 else:
97 out = "Added to existing log entry." 98 out = "Added to existing log entry."
98 log_entry.content = log_entry.content + "\n" + new_log_data 99 log_entry.content = log_entry.content + "\n" + new_log_data
99 100
100 if new_entry or not log_entries: 101 if new_entry or not log_entries:
101 log_entry = LogEntry(content=new_log_data, is_no_needs_rebaseline=no _needs_rebaseline) 102 log_entry = LogEntry(content=new_log_data, is_no_needs_rebaseline=no _needs_rebaseline)
102 103
103 log_entry.put() 104 try:
105 log_entry.put()
106 except BadRequestError:
107 out = "Created new log entry because the previous one exceeded the m ax length."
108 LogEntry(content=new_log_data, is_no_needs_rebaseline=no_needs_rebas eline).put()
109
104 self.response.out.write(out) 110 self.response.out.write(out)
105 111
106 112
107 class UploadForm(webapp2.RequestHandler): 113 class UploadForm(webapp2.RequestHandler):
108 def get(self): 114 def get(self):
109 self.response.out.write(template.render("uploadform.html", { 115 self.response.out.write(template.render("uploadform.html", {
110 "update_log_url": "/updatelog", 116 "update_log_url": "/updatelog",
111 "set_no_needs_rebaseline_url": "/noneedsrebaselines", 117 "set_no_needs_rebaseline_url": "/noneedsrebaselines",
112 "log_param": LOG_PARAM, 118 "log_param": LOG_PARAM,
113 "new_entry_param": NEW_ENTRY_PARAM, 119 "new_entry_param": NEW_ENTRY_PARAM,
(...skipping 20 matching lines...) Expand all
134 })) 140 }))
135 141
136 142
137 routes = [ 143 routes = [
138 ('/uploadform', UploadForm), 144 ('/uploadform', UploadForm),
139 ('/updatelog', UpdateLog), 145 ('/updatelog', UpdateLog),
140 ('/', ShowLatest), 146 ('/', ShowLatest),
141 ] 147 ]
142 148
143 app = webapp2.WSGIApplication(routes, debug=True) 149 app = webapp2.WSGIApplication(routes, debug=True)
OLDNEW
« no previous file with comments | « no previous file | Tools/RebaselineLogServer/main_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698