asekretenko commented on a change in pull request #383:
URL: https://github.com/apache/mesos/pull/383#discussion_r624707886
##########
File path: src/python/cli_new/lib/cli/http.py
##########
@@ -38,20 +38,29 @@ def read_endpoint(addr, endpoint, query=None):
except Exception as exception:
raise CLIException("Unable to sanitize address '{addr}': {error}"
.format(addr=addr, error=str(exception)))
-
try:
url = "{addr}/{endpoint}".format(addr=addr, endpoint=endpoint)
if query is not None:
- url += "?{query}".format(query=urllib.parse.urlencode(query))
- http_response = urllib.request.urlopen(url).read().decode("utf-8")
+ url += "?{query}".format(query=urlencode(query))
+ if config.principal() is not None and config.secret() is not None:
+ headers = urllib3.make_headers(
+ basic_auth=config.principal() + ":" + config.secret()
+ )
+ else:
+ headers = None
+ http = urllib3.PoolManager()
+ http_response = http.request('GET', url, headers=headers)
except Exception as exception:
+ print(exception)
Review comment:
The call site in `get_json()` might be a better place to print the
exception (see my other comment below).
For example, if `http_response.data.decode('utf-8')` in this function fails
for some reason on every attempt, `get_json()` will be silently crashlooping.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]