I need to determine state of last build (success/failure) and I do it like this:
report_url = 'http://.../ViewLatestBuildReport.aspx' success_marker = '<td class='header-title' colspan='2'>BUILD SUCCESSFUL</td>' page = urllib.urlopen(report_url) if all(success_marker not in line for line in page): # build is not good, do something ...
But this is wasteful (loads entire HTML page), error-prone (I already ran into a bytes/unicode bug) and fragile.
OK, I sort of figured it out. CCTray tracks build status by polling
XmlServerReport.aspx, which is (surprise!) XML.So my current solution looks like this:
In my environment it is about 8 times faster than initial HTML-based solution.