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 from __future__ import with_statement | 5 from __future__ import with_statement |
6 | 6 |
7 import datetime | 7 import datetime |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 # Map(k,v): k=Master, v=Dict of category data | 291 # Map(k,v): k=Master, v=Dict of category data |
292 self.category_data = {} | 292 self.category_data = {} |
293 | 293 |
294 self.category_count = 0 | 294 self.category_count = 0 |
295 self.master = '' | 295 self.master = '' |
296 self.lastRevisionSeen = None | 296 self.lastRevisionSeen = None |
297 self.lastMasterSeen = None | 297 self.lastMasterSeen = None |
298 | 298 |
299 @staticmethod | 299 @staticmethod |
300 def ContentsToHtml(contents): | 300 def ContentsToHtml(contents): |
301 return ''.join([str(content) for content in contents]) | 301 return ''.join(unicode(content).encode('ascii', 'replace') |
| 302 for content in contents) |
302 | 303 |
303 @property | 304 @property |
304 def last_row(self): | 305 def last_row(self): |
305 return self.row_data[self.lastRevisionSeen] | 306 return self.row_data[self.lastRevisionSeen] |
306 | 307 |
307 def SawMaster(self, master): | 308 def SawMaster(self, master): |
308 self.lastMasterSeen = master | 309 self.lastMasterSeen = master |
309 assert(self.lastMasterSeen not in self.category_order) | 310 assert(self.lastMasterSeen not in self.category_order) |
310 self.masters.append(self.lastMasterSeen) | 311 self.masters.append(self.lastMasterSeen) |
311 self.category_order.setdefault(self.lastMasterSeen, []) | 312 self.category_order.setdefault(self.lastMasterSeen, []) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 363 |
363 def ParseRow(self, row): | 364 def ParseRow(self, row): |
364 cells = row.findAll('td', recursive=False) | 365 cells = row.findAll('td', recursive=False) |
365 # Figure out which row this is. | 366 # Figure out which row this is. |
366 for attrname, attrvalue in cells[0].attrs: | 367 for attrname, attrvalue in cells[0].attrs: |
367 if attrname != 'class': | 368 if attrname != 'class': |
368 continue | 369 continue |
369 attrvalue = re.sub(r'^(\S+).*', r'\1', attrvalue) | 370 attrvalue = re.sub(r'^(\S+).*', r'\1', attrvalue) |
370 if attrvalue == 'DevRev': | 371 if attrvalue == 'DevRev': |
371 revision = cells[0] | 372 revision = cells[0] |
372 self.SawRevision(revision=revision.findAll('a')[0].contents[0]) | 373 self.SawRevision(self.ContentsToHtml( |
373 self.SetLink(revlink=revision.findAll('a')[0].attrs[0][1]) | 374 revision.findAll('a')[0].contents[0])) |
| 375 self.SetLink(self.ContentsToHtml(revision.findAll('a')[0].attrs[0][1])) |
374 nameparts = cells[1].contents | 376 nameparts = cells[1].contents |
375 self.SetName(who=re.sub(r'^\s+(.*)\s*$', | 377 self.SetName(re.sub(r'^\s+(.*)\s*$', |
376 r'\1', | 378 r'\1', |
377 self.ContentsToHtml(nameparts))) | 379 self.ContentsToHtml(nameparts))) |
378 for i, bs in enumerate(cells[2:]): | 380 for i, bs in enumerate(cells[2:]): |
379 self.SetStatus(category=self.category_order[self.lastMasterSeen][i], | 381 self.SetStatus(self.category_order[self.lastMasterSeen][i], |
380 status=str(bs.findAll('table', recursive=False)[0])) | 382 self.ContentsToHtml(bs.findAll('table', |
| 383 recursive=False)[0])) |
381 if attrvalue == 'DevComment': | 384 if attrvalue == 'DevComment': |
382 self.SetComment(comment=self.ContentsToHtml(cells[0].contents)) | 385 self.SetComment(comment=self.ContentsToHtml(cells[0].contents)) |
383 if attrvalue == 'DevDetails': | 386 if attrvalue == 'DevDetails': |
384 self.SetDetail(detail=self.ContentsToHtml(cells[0].contents)) | 387 self.SetDetail(detail=self.ContentsToHtml(cells[0].contents)) |
385 | 388 |
386 def Finish(self): | 389 def Finish(self): |
387 self.row_orderedkeys = sorted(self.row_orderedkeys, key=int, reverse=True) | 390 self.row_orderedkeys = sorted(self.row_orderedkeys, key=int, reverse=True) |
388 # TODO(cmp): Look for row/master/categories that are unset. If they are | 391 # TODO(cmp): Look for row/master/categories that are unset. If they are |
389 # at the latest revisions, leave them unset. If they are at | 392 # at the latest revisions, leave them unset. If they are at |
390 # the earliest revisions, set them to ''. | 393 # the earliest revisions, set them to ''. |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 # LKGR JSON. | 1197 # LKGR JSON. |
1195 { | 1198 { |
1196 'remoteurl': | 1199 'remoteurl': |
1197 ('http://build.chromium.org/p/chromium.lkgr/json/builders/Linux%20x64/' | 1200 ('http://build.chromium.org/p/chromium.lkgr/json/builders/Linux%20x64/' |
1198 'builds/-1?as_text=1'), | 1201 'builds/-1?as_text=1'), |
1199 'localpath': | 1202 'localpath': |
1200 'chromium.lkgr/json/builders/Linux%20x64/builds/-1/as_text=1.json', | 1203 'chromium.lkgr/json/builders/Linux%20x64/builds/-1/as_text=1.json', |
1201 'maxage': 2*60, # 2 mins | 1204 'maxage': 2*60, # 2 mins |
1202 }, | 1205 }, |
1203 ] | 1206 ] |
OLD | NEW |