Files
chromium_depot_tools/upload_metrics.py
Aravind Vasudevan bb14391a50 Remove unused imports from depot_tools scripts
This change removes some unused imports across depot_tools scripts.

Change-Id: Ic1112065ad1020fc4a3573d3fb9f137915ef439c
Bug: 1475776
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4812185
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2023-08-25 17:35:14 +00:00

34 lines
824 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 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())