From a100968232c7492ab0de26897ff019e5784d4d38 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Fri, 12 Jan 2024 16:38:51 +0000 Subject: [PATCH] [python3.12] Fix syntax warnings in utils.py scripts Bug: https://github.com/dart-lang/sdk/issues/54306 Change-Id: I3abfac0765721246b59451152d322a111d685644 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346022 Commit-Queue: William Hesse Reviewed-by: William Hesse Auto-Submit: Alexander Thomas --- runtime/tools/utils.py | 2 +- tools/utils.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/runtime/tools/utils.py b/runtime/tools/utils.py index a70681da9d1..c5e761f7e4b 100644 --- a/runtime/tools/utils.py +++ b/runtime/tools/utils.py @@ -60,7 +60,7 @@ def GuessCpus(): if os.path.exists("/usr/bin/hostinfo"): return int( getoutput( - '/usr/bin/hostinfo | GREP_OPTIONS= grep "processors are logically available." | awk "{ print \$1 }"' + '/usr/bin/hostinfo | GREP_OPTIONS= grep "processors are logically available." | awk "{ print \\$1 }"' )) win_cpu_count = os.getenv("NUMBER_OF_PROCESSORS") if win_cpu_count: diff --git a/tools/utils.py b/tools/utils.py index 13b584389c4..d3b38c5090e 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -307,7 +307,7 @@ def GuessCpus(): subprocess.check_output( '/usr/bin/hostinfo |' ' grep "processors are logically available." |' - ' awk "{ print \$1 }"', + ' awk "{ print \\$1 }"', shell=True)) win_cpu_count = os.getenv("NUMBER_OF_PROCESSORS") if win_cpu_count: @@ -398,11 +398,11 @@ def ReadVersionFile(version_file=None): return None channel = match_against('^CHANNEL ([A-Za-z0-9]+)$', content) - major = match_against('^MAJOR (\d+)$', content) - minor = match_against('^MINOR (\d+)$', content) - patch = match_against('^PATCH (\d+)$', content) - prerelease = match_against('^PRERELEASE (\d+)$', content) - prerelease_patch = match_against('^PRERELEASE_PATCH (\d+)$', content) + major = match_against('^MAJOR (\\d+)$', content) + minor = match_against('^MINOR (\\d+)$', content) + patch = match_against('^PATCH (\\d+)$', content) + prerelease = match_against('^PRERELEASE (\\d+)$', content) + prerelease_patch = match_against('^PRERELEASE_PATCH (\\d+)$', content) if (channel and major and minor and prerelease and prerelease_patch): return Version(channel, major, minor, patch, prerelease, @@ -1009,6 +1009,7 @@ def Main(): print('IsWindows() -> ', IsWindows()) print('GetGitRevision() -> ', GetGitRevision()) print('GetGitTimestamp() -> ', GetGitTimestamp()) + print('ReadVersionFile() -> ', ReadVersionFile()) if __name__ == '__main__':