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

Unified Diff: appengine/findit/waterfall/buildbot.py

Issue 2400453002: [Findit] Retrieve recent builds of a given builder. (Closed)
Patch Set: Created 4 years, 2 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 | appengine/findit/waterfall/test/buildbot_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/waterfall/buildbot.py
diff --git a/appengine/findit/waterfall/buildbot.py b/appengine/findit/waterfall/buildbot.py
index 01ffb61ee4b2fbd59fe5562d17c77456909cdb6d..e6ae1f9f35b9a7a1e029e531042d3a86228bbc98 100644
--- a/appengine/findit/waterfall/buildbot.py
+++ b/appengine/findit/waterfall/buildbot.py
@@ -5,6 +5,7 @@
import contextlib
from datetime import datetime
import gzip
+import logging
import json
import re
import urllib
@@ -29,6 +30,24 @@ _STEP_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/'
SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, CANCELLED = range(7)
+def GetRecentCompletedBuilds(master_name, builder_name, http_client):
+ """Returns a sorted list of recent completed builds for the given builder.
+
+ Sorted by completed time, newer builds at beginning of the returned list.
+ """
+ url = 'https://build.chromium.org/p/%s/json/builders/' % master_name
+ status_code, data = http_client.Get(url)
+ if status_code != 200:
+ logging.error('Failed to retrieve recent builds for %s/%s',
+ master_name, builder_name)
+ return []
+ data_json = json.loads(data)
+ metadata = data_json.get(builder_name, {})
+ cachedBuilds = metadata.get('cachedBuilds', [])
+ currentBuilds = metadata.get('currentBuilds', [])
+ return sorted(set(cachedBuilds) - set(currentBuilds), reverse=True)
+
+
def GetMasterNameFromUrl(url):
"""Parses the given url and returns the master name."""
if not url:
« no previous file with comments | « no previous file | appengine/findit/waterfall/test/buildbot_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698