git-cl: Fix "git cl tree" issues with Python 3.

* First, we were treating the return value of HTTPResponse.read() as a
  string when it is really a byte string.

* Second, the urlparse library was renamed to urllib.parse in Python 3,
  so I made the appropriate substitution.

Change-Id: I0b23716e990eca8ddf77742f378ab54eda3d3717
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2307509
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dan McArdle <dmcardle@chromium.org>
changes/09/2307509/3
Daniel McArdle 5 years ago committed by LUCI CQ
parent 39d317835b
commit 8b4eeffd46

@ -4288,7 +4288,7 @@ def GetTreeStatus(url=None):
'unknown' or 'unset'."""
url = url or settings.GetTreeStatusUrl(error_ok=True)
if url:
status = urllib.request.urlopen(url).read().lower()
status = str(urllib.request.urlopen(url).read().lower())
if status.find('closed') != -1 or status == '0':
return 'closed'
elif status.find('open') != -1 or status == '1':
@ -4301,7 +4301,7 @@ def GetTreeStatusReason():
"""Fetches the tree status from a json url and returns the message
with the reason for the tree to be opened or closed."""
url = settings.GetTreeStatusUrl()
json_url = urlparse.urljoin(url, '/current?format=json')
json_url = urllib.parse.urljoin(url, '/current?format=json')
connection = urllib.request.urlopen(json_url)
status = json.loads(connection.read())
connection.close()

Loading…
Cancel
Save