| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from datetime import datetime | 5 from datetime import datetime |
| 6 import logging | 6 import logging |
| 7 import textwrap | 7 import textwrap |
| 8 | 8 |
| 9 from google.appengine.ext import ndb | 9 from google.appengine.ext import ndb |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 _UpdateNotificationStatus(repo_name, revision, | 86 _UpdateNotificationStatus(repo_name, revision, |
| 87 status.COMPLETED if sent else status.ERROR) | 87 status.COMPLETED if sent else status.ERROR) |
| 88 return sent | 88 return sent |
| 89 | 89 |
| 90 | 90 |
| 91 def _GetCulpritInfo(repo_name, revision): | 91 def _GetCulpritInfo(repo_name, revision): |
| 92 """Returns commit position/time and code-review url of the given revision.""" | 92 """Returns commit position/time and code-review url of the given revision.""" |
| 93 # TODO(stgao): get repo url at runtime based on the given repo name. | 93 # TODO(stgao): get repo url at runtime based on the given repo name. |
| 94 # unused arg - pylint: disable=W0612,W0613 | 94 # unused arg - pylint: disable=W0612,W0613 |
| 95 repo = GitilesRepository( | 95 repo = GitilesRepository( |
| 96 'https://chromium.googlesource.com/chromium/src.git', HttpClient()) | 96 HttpClient(), 'https://chromium.googlesource.com/chromium/src.git') |
| 97 change_log = repo.GetChangeLog(revision) | 97 change_log = repo.GetChangeLog(revision) |
| 98 return change_log.commit_position, change_log.code_review_url | 98 return change_log.commit_position, change_log.code_review_url |
| 99 | 99 |
| 100 | 100 |
| 101 def _WithinNotificationTimeLimit(build_end_time, latency_limit_minutes): | 101 def _WithinNotificationTimeLimit(build_end_time, latency_limit_minutes): |
| 102 """Returns True if it is still in time to send notification.""" | 102 """Returns True if it is still in time to send notification.""" |
| 103 latency_seconds = (time_util.GetUTCNow() - build_end_time).total_seconds() | 103 latency_seconds = (time_util.GetUTCNow() - build_end_time).total_seconds() |
| 104 return latency_seconds <= latency_limit_minutes * 60 | 104 return latency_seconds <= latency_limit_minutes * 60 |
| 105 | 105 |
| 106 | 106 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 132 'within_time_limit': within_time_limit | 132 'within_time_limit': within_time_limit |
| 133 } | 133 } |
| 134 | 134 |
| 135 if not _ShouldSendNotification( | 135 if not _ShouldSendNotification( |
| 136 master_name, builder_name, build_number, repo_name, | 136 master_name, builder_name, build_number, repo_name, |
| 137 revision, commit_position, build_num_threshold, additional_criteria, | 137 revision, commit_position, build_num_threshold, additional_criteria, |
| 138 send_notification_right_now): | 138 send_notification_right_now): |
| 139 return False | 139 return False |
| 140 return _SendNotificationForCulprit( | 140 return _SendNotificationForCulprit( |
| 141 repo_name, revision, commit_position, code_review_url) | 141 repo_name, revision, commit_position, code_review_url) |
| OLD | NEW |