mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
ninjalog_uploader: Handles urllib.error.HTTPError
Bug: 350886098 Change-Id: I5d25c2b979da103b8ab6e61742d5a8da0c07b19d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5675205 Reviewed-by: Fumitoshi Ukai <ukai@google.com> Commit-Queue: Junji Watanabe <jwata@google.com> Auto-Submit: Junji Watanabe <jwata@google.com>
This commit is contained in:
@@ -251,19 +251,28 @@ def main():
|
||||
logging.info("send metadata: %s", json.dumps(metadata))
|
||||
g.write(json.dumps(metadata).encode())
|
||||
|
||||
resp = urllib.request.urlopen(
|
||||
urllib.request.Request(
|
||||
"https://" + args.server + "/upload_ninja_log/",
|
||||
data=output.getvalue(),
|
||||
headers={"Content-Encoding": "gzip"},
|
||||
))
|
||||
status = None
|
||||
err_msg = ""
|
||||
try:
|
||||
resp = urllib.request.urlopen(
|
||||
urllib.request.Request(
|
||||
"https://" + args.server + "/upload_ninja_log/",
|
||||
data=output.getvalue(),
|
||||
headers={"Content-Encoding": "gzip"},
|
||||
))
|
||||
status = resp.status
|
||||
logging.info("response header: %s", resp.headers)
|
||||
logging.info("response content: %s", resp.read())
|
||||
except urllib.error.HTTPError as e:
|
||||
status = e.status
|
||||
err_msg = e.msg
|
||||
|
||||
if resp.status != 200:
|
||||
logging.warning("unexpected status code for response: %s", resp.status)
|
||||
if status != 200:
|
||||
logging.warning(
|
||||
"unexpected status code for response: status: %s, msg: %s", status,
|
||||
err_msg)
|
||||
return 1
|
||||
|
||||
logging.info("response header: %s", resp.headers)
|
||||
logging.info("response content: %s", resp.read())
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user