| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 # 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 |
| 41 # lines in TestExpectations to avoid cluttering the log with useless | 41 # lines in TestExpectations to avoid cluttering the log with useless |
| 42 # entries every 30 seconds. | 42 # entries every 30 seconds. |
| 43 # | 43 # |
| 44 # 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 |
| 45 # entry until they have the newentry parameter, in which case, it | 45 # entry until they have the newentry parameter, in which case, it |
| 46 # starts a new log entry. | 46 # starts a new log entry. |
| 47 | 47 |
| 48 LOG_PARAM = "log" | 48 LOG_PARAM = "log" |
| 49 NEW_ENTRY_PARAM = "newentry" | 49 NEW_ENTRY_PARAM = "newentry" |
| 50 # FIXME: no_needs_rebaseline is never used anymore. Remove support for it. |
| 51 # Instead, add UI to logs.html to collapse short entries. |
| 50 NO_NEEDS_REBASELINE_PARAM = "noneedsrebaseline" | 52 NO_NEEDS_REBASELINE_PARAM = "noneedsrebaseline" |
| 51 NUM_LOGS_PARAM = "numlogs" | 53 NUM_LOGS_PARAM = "numlogs" |
| 52 BEFORE_PARAM = "before" | 54 BEFORE_PARAM = "before" |
| 53 | 55 |
| 54 | 56 |
| 55 class LogEntry(ndb.Model): | 57 class LogEntry(ndb.Model): |
| 56 content = ndb.TextProperty() | 58 content = ndb.TextProperty() |
| 57 date = ndb.DateTimeProperty(auto_now_add=True) | 59 date = ndb.DateTimeProperty(auto_now_add=True) |
| 58 is_no_needs_rebaseline = ndb.BooleanProperty() | 60 is_no_needs_rebaseline = ndb.BooleanProperty() |
| 59 | 61 |
| 60 | 62 |
| 61 def logs_query(): | 63 def logs_query(): |
| 62 return LogEntry.query().order(-LogEntry.date) | 64 return LogEntry.query().order(-LogEntry.date) |
| 63 | 65 |
| 64 | 66 |
| 65 class UpdateLog(webapp2.RequestHandler): | 67 class UpdateLog(webapp2.RequestHandler): |
| 66 def post(self): | 68 def post(self): |
| 67 new_log_data = self.request.POST.get(LOG_PARAM) | 69 new_log_data = self.request.POST.get(LOG_PARAM) |
| 68 # This entry is set to on whenever a new auto-rebaseline run is going to | 70 # This entry is set to on whenever a new auto-rebaseline run is going to |
| 69 # start logging entries. If this is not on, then the log will get append
ed | 71 # start logging entries. If this is not on, then the log will get append
ed |
| 70 # to the most recent log entry. | 72 # to the most recent log entry. |
| 71 new_entry = self.request.POST.get(NEW_ENTRY_PARAM) == "on" | 73 new_entry = self.request.POST.get(NEW_ENTRY_PARAM) == "on" |
| 72 # The case of no NeedsRebaseline lines in TestExpectations is special-ca
sed | 74 # The case of no NeedsRebaseline lines in TestExpectations is special-ca
sed |
| 73 # to always overwrite the previous noneedsrebaseline entry in the log to | 75 # to always overwrite the previous noneedsrebaseline entry in the log to |
| 74 # avoid cluttering the log with useless empty posts. It just updates the | 76 # avoid cluttering the log with useless empty posts. It just updates the |
| 75 # date of the entry so that users can see that rebaseline-o-matic is sti
ll | 77 # date of the entry so that users can see that rebaseline-o-matic is sti
ll |
| 76 # running. | 78 # running. |
| 79 # FIXME: no_needs_rebaseline is never used anymore. Remove support for i
t. |
| 77 no_needs_rebaseline = self.request.POST.get(NO_NEEDS_REBASELINE_PARAM) =
= "on" | 80 no_needs_rebaseline = self.request.POST.get(NO_NEEDS_REBASELINE_PARAM) =
= "on" |
| 78 | 81 |
| 79 out = "Wrote new log entry." | 82 out = "Wrote new log entry." |
| 80 if not new_entry or no_needs_rebaseline: | 83 if not new_entry or no_needs_rebaseline: |
| 81 log_entries = logs_query().fetch(1) | 84 log_entries = logs_query().fetch(1) |
| 82 if log_entries: | 85 if log_entries: |
| 83 log_entry = log_entries[0] | 86 log_entry = log_entries[0] |
| 84 log_entry.date = datetime.datetime.now() | 87 log_entry.date = datetime.datetime.now() |
| 85 if no_needs_rebaseline: | 88 if no_needs_rebaseline: |
| 86 # Don't write out a new log entry for repeated no_needs_reba
seline cases. | 89 # Don't write out a new log entry for repeated no_needs_reba
seline cases. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 })) | 143 })) |
| 141 | 144 |
| 142 | 145 |
| 143 routes = [ | 146 routes = [ |
| 144 ('/uploadform', UploadForm), | 147 ('/uploadform', UploadForm), |
| 145 ('/updatelog', UpdateLog), | 148 ('/updatelog', UpdateLog), |
| 146 ('/', ShowLatest), | 149 ('/', ShowLatest), |
| 147 ] | 150 ] |
| 148 | 151 |
| 149 app = webapp2.WSGIApplication(routes, debug=True) | 152 app = webapp2.WSGIApplication(routes, debug=True) |
| OLD | NEW |