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

Unified Diff: gerrit_util.py

Issue 46413002: Switch my_activity.py to use gerrit_util for gerrit REST connections (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 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 | my_activity.py » ('j') | my_activity.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gerrit_util.py
diff --git a/gerrit_util.py b/gerrit_util.py
index 7c44f03107468de934940bd1bf7646630818c53f..effd2a7ede32ad6c609cd457e517348df480fc65 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -65,11 +65,19 @@ def CreateHttpConn(host, path, reqtype='GET', headers=None, body=None):
headers = headers or {}
bare_host = host.partition(':')[0]
auth = NETRC.authenticators(bare_host)
+ review_auth = NETRC.authenticators(bare_host.replace('-review', ''))
+
if auth:
headers.setdefault('Authorization', 'Basic %s' % (
base64.b64encode('%s:%s' % (auth[0], auth[2]))))
+ url = '/a/%s' % path
+ elif review_auth:
+ headers.setdefault('Authorization', 'Basic %s' % (
+ base64.b64encode('%s:%s' % (review_auth[0], review_auth[2]))))
+ url = '/a/%s' % path
else:
LOGGER.debug('No authorization found')
+ url = '/%s' % path
if body:
body = json.JSONEncoder().encode(body)
headers.setdefault('Content-Type', 'application/json')
@@ -84,7 +92,7 @@ def CreateHttpConn(host, path, reqtype='GET', headers=None, body=None):
conn = GetConnectionClass()(host)
conn.req_host = host
conn.req_params = {
- 'url': '/a/%s' % path,
+ 'url': url,
'method': reqtype,
'headers': headers,
'body': body,
« no previous file with comments | « no previous file | my_activity.py » ('j') | my_activity.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698