depot_tools: Make some changes to make metrics collection compatible with Python 3.
Bug: 984182
Change-Id: I55e9e83d01d5a86464cc234c083e4212f0ba4a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1713217
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/upload_metrics.py b/upload_metrics.py
index cbe2dcf..41fd193 100644
--- a/upload_metrics.py
+++ b/upload_metrics.py
@@ -4,18 +4,19 @@
# found in the LICENSE file.
import sys
-import urllib2
+
+from third_party.six.moves import urllib
+from third_party.six.moves import input # pylint: disable=redefined-builtin
import metrics_utils
def main():
- metrics = raw_input()
+ metrics = input()
try:
- urllib2.urlopen(metrics_utils.APP_URL + '/upload', metrics)
- except urllib2.HTTPError:
- pass
- except urllib2.URLError:
+ urllib.request.urlopen(
+ metrics_utils.APP_URL + '/upload', metrics.encode('utf-8'))
+ except (urllib.error.HTTPError, urllib.error.URLError):
pass
return 0