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/metrics.py b/metrics.py
index 5cdd96a..37f3a8a 100644
--- a/metrics.py
+++ b/metrics.py
@@ -185,7 +185,7 @@
# so that we are able to return immediately, leaving the upload running in
# the background.
p = subprocess.Popen([sys.executable, UPLOAD_SCRIPT], stdin=subprocess.PIPE)
- p.stdin.write(json.dumps(self._reported_metrics))
+ p.stdin.write(json.dumps(self._reported_metrics).encode('utf-8'))
def _collect_metrics(self, func, command_name, *args, **kwargs):
# If we're already collecting metrics, just execute the function.