diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-07-07 12:17:43 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-07 12:17:43 +0900 |
| commit | 7be29c1627d741f300e05ffb7d0ac430005d12e1 (patch) | |
| tree | 039476bdd03da5853b8fdf46e7f766e3adc5f110 | |
| parent | fe3d6a74d9483a8c0f74c80c3b647e07e5ce7a6d (diff) | |
| parent | 0b3653bbdd70ff0c19edc5c59a794f4c4cd86f31 (diff) | |
| download | rust-7be29c1627d741f300e05ffb7d0ac430005d12e1.tar.gz rust-7be29c1627d741f300e05ffb7d0ac430005d12e1.zip | |
Rollup merge of #86907 - pietroalbini:ci-cpu-stats-python3, r=Mark-Simulacrum
Migrate `cpu-usage-over-time.py` to Python 3
The only change here is a fix for `sys.platform` on Linux. Python 3.3 changed the API to return `"linux"` instead of `"linux2"`/`"linux3"`, so this PR uses `.startswith("linux")` to make the code work on Python 3 without breaking Python 2.
| -rw-r--r-- | src/ci/cpu-usage-over-time.py | 7 | ||||
| -rwxr-xr-x | src/ci/scripts/collect-cpu-stats.sh | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/ci/cpu-usage-over-time.py b/src/ci/cpu-usage-over-time.py index 78ac0603681..267c3964d0d 100644 --- a/src/ci/cpu-usage-over-time.py +++ b/src/ci/cpu-usage-over-time.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # ignore-tidy-linelength # This is a small script that we use on CI to collect CPU usage statistics of @@ -37,7 +37,10 @@ import datetime import sys import time -if sys.platform == 'linux2': +# Python 3.3 changed the value of `sys.platform` on Linux from "linux2" to just +# "linux". We check here with `.startswith` to keep compatibility with older +# Python versions (especially Python 2.7). +if sys.platform.startswith('linux'): class State: def __init__(self): with open('/proc/stat', 'r') as file: diff --git a/src/ci/scripts/collect-cpu-stats.sh b/src/ci/scripts/collect-cpu-stats.sh index 08065431f98..853b4628fab 100755 --- a/src/ci/scripts/collect-cpu-stats.sh +++ b/src/ci/scripts/collect-cpu-stats.sh @@ -6,4 +6,4 @@ set -euo pipefail IFS=$'\n\t' -python src/ci/cpu-usage-over-time.py &> cpu-usage.csv & +python3 src/ci/cpu-usage-over-time.py &> cpu-usage.csv & |
