Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3366)

Unified Diff: dashboard/dashboard/common/utils.py

Issue 2620713002: Factored stdio parsing out of graph_json. (Closed)
Patch Set: fix more typos in unit tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dashboard/dashboard/common/utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/common/utils.py
diff --git a/dashboard/dashboard/common/utils.py b/dashboard/dashboard/common/utils.py
index 2c79ffd42829adccc0cbb4b0f2d7adcb73f552c5..4e2350b43cab19930990188a5332e043d293ffa0 100644
--- a/dashboard/dashboard/common/utils.py
+++ b/dashboard/dashboard/common/utils.py
@@ -9,6 +9,7 @@ import logging
import os
import re
import time
+import urllib
from apiclient import discovery
from apiclient import errors
@@ -464,3 +465,42 @@ def FetchURL(request_url, skip_status_code=False):
'ERROR %s checking %s', response.status_code, request_url)
return None
return response
+
+
+def GetBuildDetailsFromStdioLink(stdio_link):
+ no_details = (None, None, None, None, None)
eakuefner 2017/01/09 21:45:19 I'm a little worried about using such a large tupl
sullivan 2017/01/09 22:20:36 I think it's okay because this method is mostly us
+ m = re.match(r'\[(.+?)\]\((.+?)\)', stdio_link)
+ if not m:
+ # This wasn't the markdown-style link we were expecting.
+ return no_details
+ _, link = m.groups()
+ m = re.match(
+ r'(https{0,1}://.*/([^\/]*)/builders/)'
+ r'([^\/]+)/builds/(\d+)/steps/([^\/]+)', link)
+ if not m:
+ # This wasn't a buildbot formatted link.
+ return no_details
+ base_url, master, bot, buildnumber, step = m.groups()
+ bot = urllib.unquote(bot)
+ return base_url, master, bot, buildnumber, step
+
+
+def GetBuildbotStatusPageUriFromStdioLink(stdio_link):
+ base_url, _, bot, buildnumber, _ = GetBuildDetailsFromStdioLink(
+ stdio_link)
+ if not base_url:
+ # Can't parse status page
+ return None
+ return '%s%s/builds/%s' % (base_url, urllib.quote(bot), buildnumber)
+
+
+def GetLogdogLogUriFromStdioLink(stdio_link):
+ base_url, master, bot, buildnumber, step = GetBuildDetailsFromStdioLink(
+ stdio_link)
+ if not base_url:
+ # Can't parse status page
+ return None
+ bot = re.sub(r'[ \(\)]', '_', bot)
eakuefner 2017/01/09 21:45:19 Is this needed because it's a substitution that Lo
sullivan 2017/01/09 22:20:36 Yes, exactly, logdog does totally different substi
+ s_param = urllib.quote('chrome/bb/%s/%s/%s/+/recipes/steps/%s/0/stdout' % (
+ master, bot, buildnumber, step), safe='')
+ return 'https://luci-logdog.appspot.com/v/?s=%s' % s_param
« no previous file with comments | « no previous file | dashboard/dashboard/common/utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698