RCS file: /cvsroot/mozilla/tools/buildbot/buildbot/changes/bonsaipoller.py,v
retrieving revision 1.5
diff -u -r1.5 bonsaipoller.py
|
|
|
|
| 1 | 1 | import time |
| 2 | | from urllib import urlopen |
| 3 | 2 | from xml.dom import minidom, Node |
| 4 | 3 | |
| 5 | 4 | from twisted.python import log, failure |
| 6 | 5 | from twisted.internet import defer, reactor |
| 7 | 6 | from twisted.internet.task import LoopingCall |
| | 7 | from twisted.web.client import getPage |
| 8 | 8 | |
| 9 | 9 | from buildbot.changes import base, changes |
| 10 | 10 | |
| … |
… |
|
| 64 | 64 | class BonsaiParser: |
| 65 | 65 | """I parse the XML result from a bonsai cvsquery.""" |
| 66 | 66 | |
| 67 | | def __init__(self, bonsaiQuery): |
| | 67 | def __init__(self, data): |
| 68 | 68 | try: |
| 69 | 69 | # this is a fix for non-ascii characters |
| 70 | | # readlines() + join is being used because read() is not guaranteed |
| 71 | | # to work. because bonsai does not give us an encoding to work with |
| | 70 | # because bonsai does not give us an encoding to work with |
| 72 | 71 | # it impossible to be 100% sure what to decode it as but latin1 covers |
| 73 | 72 | # the broadest base |
| 74 | | data = "".join(bonsaiQuery.readlines()) |
| 75 | 73 | data = data.decode("latin1") |
| 76 | 74 | data = data.encode("ascii", "replace") |
| 77 | 75 | self.dom = minidom.parseString(data) |
| … |
… |
|
| 290 | 288 | |
| 291 | 289 | self.lastPoll = time.time() |
| 292 | 290 | # get the page, in XML format |
| 293 | | return defer.maybeDeferred(urlopen, url) |
| | 291 | return getPage(url, timeout=self.pollInterval) |
| 294 | 292 | |
| 295 | 293 | def _process_changes(self, query): |
| 296 | 294 | try: |