| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import datetime | 5 import datetime |
| 6 import hashlib | 6 import hashlib |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import pytz | 9 import pytz |
| 10 import time | 10 import time |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 base.PollingChangeSource.setServiceParent(self, parent) | 237 base.PollingChangeSource.setServiceParent(self, parent) |
| 238 self._try_job_rietveld = parent | 238 self._try_job_rietveld = parent |
| 239 | 239 |
| 240 @defer.inlineCallbacks | 240 @defer.inlineCallbacks |
| 241 def _InitProcessedKeysCache(self): | 241 def _InitProcessedKeysCache(self): |
| 242 log.msg('[RPWC] Initializing processed keys cache...') | 242 log.msg('[RPWC] Initializing processed keys cache...') |
| 243 | 243 |
| 244 # Get all BuildBot build requests. | 244 # Get all BuildBot build requests. |
| 245 brdicts = yield self.master.db.buildrequests.getBuildRequests() | 245 brdicts = yield self.master.db.buildrequests.getBuildRequests() |
| 246 | 246 |
| 247 log.msg('[RPWC] Received build request dicts') | 247 log.msg('[RPWC] Received %d build request dicts' % len(brdicts)) |
| 248 | 248 |
| 249 def asNaiveUTC(dt): | 249 def asNaiveUTC(dt): |
| 250 if dt is None: | 250 if dt is None: |
| 251 return datetime.datetime.now() | 251 return datetime.datetime.now() |
| 252 if dt.tzinfo is None: | 252 if dt.tzinfo is None: |
| 253 return dt | 253 return dt |
| 254 utc_datetime = dt.astimezone(pytz.utc) | 254 utc_datetime = dt.astimezone(pytz.utc) |
| 255 return utc_datetime.replace(tzinfo=None) | 255 return utc_datetime.replace(tzinfo=None) |
| 256 | 256 |
| 257 # Compose a map of buildset ids to the submission timestamp. | 257 # Compose a map of buildset ids to the submission timestamp. |
| 258 buildsets = {} | 258 buildsets = {} |
| 259 for brdict in brdicts: | 259 for brdict in brdicts: |
| 260 bsid = brdict.get('buildsetid') | 260 bsid = brdict.get('buildsetid') |
| 261 if bsid is not None: | 261 if bsid is not None: |
| 262 buildsets[bsid] = asNaiveUTC(brdict.get('submitted_at')) | 262 buildsets[bsid] = asNaiveUTC(brdict.get('submitted_at')) |
| 263 | 263 |
| 264 log.msg('[RPWC] Processing %d buildsets' % len(buildsets)) |
| 265 |
| 264 # Find jobs for each buildset and add them to the processed keys cache. | 266 # Find jobs for each buildset and add them to the processed keys cache. |
| 265 self._processed_keys = {} | 267 self._processed_keys = {} |
| 266 for bsid in buildsets.keys(): | 268 for bsid in buildsets.keys(): |
| 267 log.msg('[RPWC] Loading properties of the buildset %d' % bsid) | 269 log.msg('[RPWC] Loading properties of the buildset %d' % bsid) |
| 268 bsprops = yield self.master.db.buildsets.getBuildsetProperties(bsid) | 270 bsprops = yield self.master.db.buildsets.getBuildsetProperties(bsid) |
| 269 if 'try_job_key' in bsprops: | 271 if 'try_job_key' in bsprops: |
| 270 key = bsprops['try_job_key'][0] | 272 key = bsprops['try_job_key'][0] |
| 271 self._processed_keys[key] = buildsets[bsid] | 273 self._processed_keys[key] = buildsets[bsid] |
| 272 | 274 |
| 273 log.msg('[RPWC] Initialized processed keys cache from master with %d ' | 275 log.msg('[RPWC] Initialized processed keys cache from master with %d ' |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 else: | 493 else: |
| 492 self.processed_keys.add(job['key']) | 494 self.processed_keys.add(job['key']) |
| 493 log.err('Rietveld not updated: no corresponding service found.') | 495 log.err('Rietveld not updated: no corresponding service found.') |
| 494 | 496 |
| 495 # TryJobBase overrides: | 497 # TryJobBase overrides: |
| 496 def setServiceParent(self, parent): | 498 def setServiceParent(self, parent): |
| 497 TryJobBase.setServiceParent(self, parent) | 499 TryJobBase.setServiceParent(self, parent) |
| 498 self._poller.setServiceParent(self) | 500 self._poller.setServiceParent(self) |
| 499 self._poller.master = self.master | 501 self._poller.master = self.master |
| 500 self._valid_users.setServiceParent(self) | 502 self._valid_users.setServiceParent(self) |
| OLD | NEW |