MCPcopy Create free account
hub / github.com/apache/mesos / read_endpoint

Function read_endpoint

src/python/cli_new/lib/cli/http.py:32–51  ·  view source on GitHub ↗

Read the specified endpoint and return the results.

(addr, endpoint, query=None)

Source from the content-addressed store, hash-verified

30
31
32def read_endpoint(addr, endpoint, query=None):
33 """
34 Read the specified endpoint and return the results.
35 """
36 try:
37 addr = cli.util.sanitize_address(addr)
38 except Exception as exception:
39 raise CLIException("Unable to sanitize address '{addr}': {error}"
40 .format(addr=addr, error=str(exception)))
41
42 try:
43 url = "{addr}/{endpoint}".format(addr=addr, endpoint=endpoint)
44 if query is not None:
45 url += "?{query}".format(query=urllib.parse.urlencode(query))
46 http_response = urllib.request.urlopen(url).read().decode("utf-8")
47 except Exception as exception:
48 raise CLIException("Unable to open url '{url}': {error}"
49 .format(url=url, error=str(exception)))
50
51 return http_response
52
53
54def get_json(addr, endpoint, condition=None, timeout=5, query=None):

Callers 1

get_jsonFunction · 0.85

Calls 3

CLIExceptionClass · 0.90
decodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected