From 587d2a1d68e9dd070af771b2581a53d9231a4d60 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Wed, 22 Jan 2020 15:37:46 +0100 Subject: [PATCH] Update cdash parse_dash_results to new API --- scripts/parse_dash_results.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/parse_dash_results.py b/scripts/parse_dash_results.py index 6e970b25cb5..c9d729752e1 100755 --- a/scripts/parse_dash_results.py +++ b/scripts/parse_dash_results.py @@ -33,7 +33,7 @@ import urllib.request import urllib.parse import urllib.error import re -from bs4 import BeautifulSoup +import json from PyQt5.QtGui import ( QImage, QColor, qRed, qBlue, qGreen, qAlpha, qRgb, QPixmap) from PyQt5.QtWidgets import (QDialog, @@ -147,19 +147,20 @@ class ResultHandler(QDialog): self.reject() def parse_url(self, url): - print('Fetching dash results from: {}'.format(url)) - page = urllib.request.urlopen(url) - soup = BeautifulSoup(page, "lxml") + parts = urllib.parse.urlsplit(url) + apiurl = urllib.parse.urlunsplit((parts.scheme, parts.netloc, '/api/v1/testDetails.php', parts.query, parts.fragment)) + print('Fetching dash results from api: {}'.format(apiurl)) + page = urllib.request.urlopen(apiurl) + content = json.loads(page.read().decode('utf-8')) # build up list of rendered images - measurement_img = [img for img in soup.find_all('img') if - img.get('alt') and img.get('alt').startswith('Rendered Image')] + measurement_img = [img for img in content['test']['images'] if img['role'].startswith('Rendered Image')] images = {} for img in measurement_img: - m = re.search('Rendered Image (.*?)(\s|$)', img.get('alt')) + m = re.search('Rendered Image (.*?)(\s|$)', img['role']) test_name = m.group(1) - rendered_image = img.get('src') + rendered_image = 'displayImage.php?imgid={}'.format(img['imgid']) images[test_name] = '{}/{}'.format(dash_url, rendered_image) if images: