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

Unified Diff: scripts/slave/gatekeeper_ng.py

Issue 895633002: Gatekeeper: use same authentication for reading status as for writing. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 5 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 | scripts/slave/unittests/gatekeeper_ng_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/gatekeeper_ng.py
diff --git a/scripts/slave/gatekeeper_ng.py b/scripts/slave/gatekeeper_ng.py
index d7abd3ea5fdde79b34147bc20c73d71fdbe3dcd1..69867b5a56b1991a929260c5962511f38cf9bb0c 100755
--- a/scripts/slave/gatekeeper_ng.py
+++ b/scripts/slave/gatekeeper_ng.py
@@ -87,9 +87,26 @@ def update_status(tree_message, status_url_root, username, password):
logging.info('success')
-def get_tree_status(status_url_root):
+def get_tree_status(status_url_root, username, password):
status_url = status_url_root + "/current?format=json"
- return json.load(logging_urlopen(status_url))
+ data = logging_urlopen(status_url).read()
+ try:
+ return json.loads(data)
+ except ValueError:
+ if 'Login Required' not in data:
+ raise
+ # try using bot password to authenticate
+ params = urllib.urlencode({
+ 'username': username,
+ 'password': password
+ })
+ try:
+ data = logging_urlopen(status_url, params).read()
+ except urllib2.HTTPError, e:
+ if e.code == 405:
+ logging.warn("update your chromium_status app.")
+ raise
+ return json.loads(data)
def get_builder_section(gatekeeper_section, builder):
@@ -509,7 +526,7 @@ def open_tree_if_possible(build_db, master_jsons, successful_builder_steps,
logging.debug(' %s' % build)
return
- status = get_tree_status(status_url_root)
+ status = get_tree_status(status_url_root, username, password)
# Don't change the status unless the tree is currently closed.
if status['general_state'] != 'closed':
return
@@ -564,7 +581,7 @@ def close_tree_if_necessary(failed_builds, username, password, status_url_root,
logging.info('no tree-closing failures!')
return
- status = get_tree_status(status_url_root)
+ status = get_tree_status(status_url_root, username, password)
# Don't change the status unless the tree is currently open.
if status['general_state'] != 'open':
return
« no previous file with comments | « no previous file | scripts/slave/unittests/gatekeeper_ng_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698