MCPcopy
hub / github.com/commaai/openpilot / api_call

Method api_call

tools/lib/github_utils.py:21–33  ·  view source on GitHub ↗
(self, path, data="", method=HTTPMethod.GET, accept="", data_call=False, raise_on_failure=True)

Source from the content-addressed store, hash-verified

19 return f"https://api.github.com/repos/{self.OWNER}/{self.DATA_REPO}"
20
21 def api_call(self, path, data="", method=HTTPMethod.GET, accept="", data_call=False, raise_on_failure=True):
22 token = self.DATA_TOKEN if data_call else self.API_TOKEN
23 if token:
24 headers = {"Authorization": f"Bearer {self.DATA_TOKEN if data_call else self.API_TOKEN}", \
25 "Accept": f"application/vnd.github{accept}+json"}
26 else:
27 headers = {}
28 path = f'{self.DATA_ROUTE if data_call else self.API_ROUTE}/{path}'
29 r = requests.request(method, path, headers=headers, data=data)
30 if not r.ok and raise_on_failure:
31 raise Exception(f"Call to {path} failed with {r.status_code}")
32 else:
33 return r
34
35 def upload_file(self, bucket, path, file_name):
36 with open(path, "rb") as f:

Callers 7

upload_fileMethod · 0.95
create_bucketMethod · 0.95
get_bucket_shaMethod · 0.95
get_file_urlMethod · 0.95
get_file_shaMethod · 0.95
get_pr_numberMethod · 0.95
comment_on_prMethod · 0.95

Calls 1

requestMethod · 0.45

Tested by

no test coverage detected