This repository has been archived on 2023-02-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-benchmark-bundle/benchmark/foundation/buildbot.py
Sergey Sharybin 3c3c8cbaad SOme ground work to support Windows for benchmark farm
Mainly straightforward changes, the only tricky part: detect number of CPU
sockets. Didn't figure out yet how to do this on Windows.
2017-08-28 15:05:04 +02:00

85 lines
2.6 KiB
Python

import os
import re
import requests
from html.parser import HTMLParser
BUILDBOT_URL = "https://builder.blender.org/"
BUILDBOT_DOWNLOAD_URL = BUILDBOT_URL + "download/"
class BuildbotHTMLParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self._is_inside_official_table = False
self._is_official_table_finished = False
self.official_builds = []
def handle_starttag(self, tag, attrs):
tag_lower = tag.lower()
if tag_lower == 'a':
if self._is_inside_official_table:
for attr in attrs:
if attr[0].lower() == 'href':
href = attr[1]
self.official_builds.append(href)
elif tag_lower == 'table':
classes = ()
for attr in attrs:
if attr[0].lower() == 'class':
classes = attr[1].lower().split()
if 'table-striped' in classes:
if self._is_inside_official_table:
self._is_inside_official_table = False
self._is_official_table_finished = True
else:
if not self._is_official_table_finished:
self._is_inside_official_table = True
def handle_endtag(self, tag):
pass
def handle_data(self, data):
pass
def _getBuildbotPlatformRegex(platform, bitness):
platform_lower = platform.lower()
if platform_lower in ("linux", "lin"):
if bitness.startswith("64"):
return re.compile(".*linux-glibc[0-9]+-x86_64.*")
elif bitness.startswith("32"):
return re.compile(".*linux-glibc[0-9]+-i686.*")
elif platform_lower in ("win32"):
if bitness.startswith("64"):
return re.compile(".*win64.*")
elif bitness.startswith("32"):
return re.compile(".*win32.*")
else:
# TOGO(sergey): Needs implementation
pass
return None
def buildbotGetLatetsVersion(platform, bitness):
"""
Get latest Blender version URL from buildbot website.
Returns None if something is wrong.
"""
# Get content of the page.
r = requests.get(BUILDBOT_DOWNLOAD_URL)
if r.status_code != requests.codes.ok:
return None
# Parse the page.
parser = BuildbotHTMLParser()
parser.feed(r.text)
official_builds = parser.official_builds
# Get build which corresponds to requested platform.
regex = _getBuildbotPlatformRegex(platform, bitness)
if not regex:
return None
for build in official_builds:
if regex.match(build):
return BUILDBOT_DOWNLOAD_URL + build
return None