mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
It's possible that remote closes connection, which would result in a stacktrace being shown in the stderr. Silence this exception, as we do with other exceptions. R=gavinmak@google.com Bug: 1328518 Change-Id: Ifae2aca64fe5d572c0b71008f6dacbb63ba77e06 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3664178 Reviewed-by: Gavin Mak <gavinmak@google.com> Auto-Submit: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
35 lines
834 B
Python
35 lines
834 B
Python
#!/usr/bin/env vpython3
|
|
# Copyright (c) 2018 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import http
|
|
import os
|
|
import sys
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
import auth
|
|
import metrics_utils
|
|
|
|
def main():
|
|
metrics = input()
|
|
try:
|
|
headers = {}
|
|
if 'bot_metrics' in metrics:
|
|
token = auth.Authenticator().get_access_token().token
|
|
headers = {'Authorization': 'Bearer ' + token}
|
|
urllib.request.urlopen(urllib.request.Request(
|
|
url=metrics_utils.APP_URL + '/upload',
|
|
data=metrics.encode('utf-8'),
|
|
headers=headers))
|
|
except (urllib.error.HTTPError, urllib.error.URLError,
|
|
http.client.RemoteDisconnected):
|
|
pass
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|