Chromium Code Reviews| 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 hashlib | 5 import hashlib |
| 6 import json | 6 import json |
| 7 import time | 7 import time |
| 8 import urllib | 8 import urllib |
| 9 import urlparse | 9 import urlparse |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 d.addErrback(log.err, 'error in ValidUserPoller') | 58 d.addErrback(log.err, 'error in ValidUserPoller') |
| 59 return d | 59 return d |
| 60 | 60 |
| 61 def _GetUsers(self, _): | 61 def _GetUsers(self, _): |
| 62 """Downloads list of valid users. | 62 """Downloads list of valid users. |
| 63 | 63 |
| 64 Returns: | 64 Returns: |
| 65 A frozenset of string containing the email addresses of users allowed to | 65 A frozenset of string containing the email addresses of users allowed to |
| 66 send jobs from Rietveld. | 66 send jobs from Rietveld. |
| 67 """ | 67 """ |
| 68 pwd = open(self._PWD_FILE).readline().strip() | 68 try: |
|
M-A Ruel
2012/07/19 11:57:28
I'd prefer a
if os.path.isfile()
and be sure to
Peter Mayo
2012/07/19 19:12:52
SGTM ... once running I'm not sure if the preferre
| |
| 69 pwd = open(self._PWD_FILE).readline().strip() | |
| 70 except IOError: | |
| 71 return frozenset([]) | |
| 72 | |
| 69 now_string = str(int(time.time())) | 73 now_string = str(int(time.time())) |
| 70 params = { | 74 params = { |
| 71 'md5': hashlib.md5(pwd + now_string).hexdigest(), | 75 'md5': hashlib.md5(pwd + now_string).hexdigest(), |
| 72 'time': now_string | 76 'time': now_string |
| 73 } | 77 } |
| 74 | |
| 75 return client.getPage('https://chromium-access.appspot.com/auto/users', | 78 return client.getPage('https://chromium-access.appspot.com/auto/users', |
| 76 agent='buildbot', | 79 agent='buildbot', |
| 77 method='POST', | 80 method='POST', |
| 78 postdata=urllib.urlencode(params)) | 81 postdata=urllib.urlencode(params)) |
| 79 | 82 |
| 80 def _MakeSet(self, data): | 83 def _MakeSet(self, data): |
| 81 """Converts the input data string into a set of email addresses. | 84 """Converts the input data string into a set of email addresses. |
| 82 """ | 85 """ |
| 83 emails = (email.strip() for email in data.splitlines()) | 86 emails = (email.strip() for email in data.splitlines()) |
| 84 self._users = frozenset(email for email in emails if email) | 87 self._users = frozenset(email for email in emails if email) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 | 236 |
| 234 for ex in exceptions: | 237 for ex in exceptions: |
| 235 log.msg(ex) | 238 log.msg(ex) |
| 236 | 239 |
| 237 # TryJobBase overrides: | 240 # TryJobBase overrides: |
| 238 def setServiceParent(self, parent): | 241 def setServiceParent(self, parent): |
| 239 TryJobBase.setServiceParent(self, parent) | 242 TryJobBase.setServiceParent(self, parent) |
| 240 self._poller.setServiceParent(self) | 243 self._poller.setServiceParent(self) |
| 241 self._poller.master = self.master | 244 self._poller.master = self.master |
| 242 self._valid_users.setServiceParent(self) | 245 self._valid_users.setServiceParent(self) |
| OLD | NEW |