Dont fail on github responses without JSON payloads
This commit is contained in:
parent
dd4051bfd5
commit
0757fcc451
1 changed files with 8 additions and 3 deletions
|
|
@ -347,9 +347,14 @@ def do_upload(self, url: str, path: str, desc: str, fname: str) -> requests.Resp
|
|||
data=cast(IO[bytes], f))
|
||||
|
||||
def print_failed_response_details(self, r: requests.Response, msg: str) -> None:
|
||||
print(msg, f' Status Code: {r.status_code}', file=sys.stderr)
|
||||
print(msg, f' Status Code: {r.status_code} {r.reason}', file=sys.stderr)
|
||||
try:
|
||||
jr = dict(r.json())
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print('JSON from response:', file=sys.stderr)
|
||||
pprint.pprint(dict(r.json()), stream=sys.stderr)
|
||||
pprint.pprint(jr, stream=sys.stderr)
|
||||
|
||||
def fail(self, r: requests.Response, msg: str) -> None:
|
||||
self.print_failed_response_details(r, msg)
|
||||
|
|
|
|||
Loading…
Reference in a new issue