From 5ff134b7fd24b251259889be9f2aee3c3b93edfa Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 30 Jul 2021 18:35:44 -0700 Subject: [PATCH 1/2] Migrate all Python hashbangs to Python 3 Migrates all `#!/usr/bin/env python` hashbang lines to use python3. Also updates the licence tool to treat python3 scripts on par with python 2 scripts. Issue: https://github.com/flutter/flutter/issues/83043 --- build/copy_info_plist.py | 2 +- build/dart/tools/dart_package_name.py | 3 ++- build/dart/tools/dart_pkg.py | 2 +- build/generate_coverage.py | 2 +- build/git_revision.py | 2 +- build/zip.py | 3 ++- ci/firebase_testlab.py | 2 +- ci/licenses_golden/tool_signature | 2 +- shell/platform/fuchsia/flutter/build/asset_package.py | 3 ++- shell/platform/fuchsia/flutter/build/gen_debug_wrapper_main.py | 3 ++- sky/tools/create_ios_framework.py | 3 ++- sky/tools/create_macos_gen_snapshots.py | 3 ++- sky/tools/create_xcframework.py | 3 ++- sky/tools/dist_dart_pkg.py | 3 ++- sky/tools/flutter_gdb | 3 ++- sky/tools/install_framework_headers.py | 3 ++- sky/tools/objcopy.py | 3 ++- sky/tools/roll/patch.py | 3 ++- sky/tools/roll/roll.py | 3 ++- sky/tools/roll/utils.py | 3 ++- testing/rules/run_gradle.py | 3 ++- testing/run_tests.py | 3 ++- tools/android_illegal_imports.py | 3 ++- tools/androidx/generate_pom_file.py | 3 ++- tools/dia_dll.py | 3 ++- tools/font-subset/test.py | 2 +- tools/fuchsia/build_fuchsia_artifacts.py | 2 +- tools/fuchsia/compile_cml.py | 2 +- tools/fuchsia/copy_debug_symbols.py | 2 +- tools/fuchsia/copy_path.py | 2 +- tools/fuchsia/gather_flutter_runner_artifacts.py | 2 +- tools/fuchsia/gen_package.py | 2 +- tools/fuchsia/gen_repo.py | 2 +- tools/fuchsia/interpolate_test_suite.py | 2 +- tools/fuchsia/make_build_info.py | 2 +- tools/fuchsia/merge_and_upload_debug_symbols.py | 2 +- tools/fuchsia/parse_manifest.py | 2 +- tools/gen_android_buildconfig.py | 3 ++- tools/gen_javadoc.py | 3 ++- tools/licenses/lib/main.dart | 2 +- 40 files changed, 61 insertions(+), 40 deletions(-) diff --git a/build/copy_info_plist.py b/build/copy_info_plist.py index a87e1a8c98867..031975b37a8b4 100644 --- a/build/copy_info_plist.py +++ b/build/copy_info_plist.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/build/dart/tools/dart_package_name.py b/build/dart/tools/dart_package_name.py index 255ef5be7a13a..db8c9e93193ed 100755 --- a/build/dart/tools/dart_package_name.py +++ b/build/dart/tools/dart_package_name.py @@ -1,4 +1,5 @@ -#!/usr/bin/python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/build/dart/tools/dart_pkg.py b/build/dart/tools/dart_pkg.py index 18d2e6951faf8..15c29cd7bace9 100755 --- a/build/dart/tools/dart_pkg.py +++ b/build/dart/tools/dart_pkg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/build/generate_coverage.py b/build/generate_coverage.py index bf675eca09c93..ae7099f47a3fe 100755 --- a/build/generate_coverage.py +++ b/build/generate_coverage.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/build/git_revision.py b/build/git_revision.py index 5ee807c3abad5..778d7e70c7d60 100755 --- a/build/git_revision.py +++ b/build/git_revision.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/build/zip.py b/build/zip.py index b257a7ad3c53c..0bcbc02fc9006 100755 --- a/build/zip.py +++ b/build/zip.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/ci/firebase_testlab.py b/ci/firebase_testlab.py index 7aef50c37918b..effd543819ecd 100755 --- a/ci/firebase_testlab.py +++ b/ci/firebase_testlab.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/ci/licenses_golden/tool_signature b/ci/licenses_golden/tool_signature index 994a643c462a4..5ee671d62fe4b 100644 --- a/ci/licenses_golden/tool_signature +++ b/ci/licenses_golden/tool_signature @@ -1,2 +1,2 @@ -Signature: 17e2c7f169a5804317b8f79ab1f8a838 +Signature: fdaf33383efb94fa6bbc158cbc25635c diff --git a/shell/platform/fuchsia/flutter/build/asset_package.py b/shell/platform/fuchsia/flutter/build/asset_package.py index 90c98fdd2f085..5ec916f5ff027 100755 --- a/shell/platform/fuchsia/flutter/build/asset_package.py +++ b/shell/platform/fuchsia/flutter/build/asset_package.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/shell/platform/fuchsia/flutter/build/gen_debug_wrapper_main.py b/shell/platform/fuchsia/flutter/build/gen_debug_wrapper_main.py index c16a6feca7497..d5811d5cddb05 100755 --- a/shell/platform/fuchsia/flutter/build/gen_debug_wrapper_main.py +++ b/shell/platform/fuchsia/flutter/build/gen_debug_wrapper_main.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/create_ios_framework.py b/sky/tools/create_ios_framework.py index 6ceaa658f3aa0..67092cac3b6e9 100755 --- a/sky/tools/create_ios_framework.py +++ b/sky/tools/create_ios_framework.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/create_macos_gen_snapshots.py b/sky/tools/create_macos_gen_snapshots.py index af833076fec81..301f91cf28a8e 100755 --- a/sky/tools/create_macos_gen_snapshots.py +++ b/sky/tools/create_macos_gen_snapshots.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/create_xcframework.py b/sky/tools/create_xcframework.py index 0bdc952e61798..9bd0609457dbe 100755 --- a/sky/tools/create_xcframework.py +++ b/sky/tools/create_xcframework.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/dist_dart_pkg.py b/sky/tools/dist_dart_pkg.py index af8bd1dbb201d..2a01a571e3ae2 100755 --- a/sky/tools/dist_dart_pkg.py +++ b/sky/tools/dist_dart_pkg.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/flutter_gdb b/sky/tools/flutter_gdb index 0d2fa2adb8601..273952f415f78 100755 --- a/sky/tools/flutter_gdb +++ b/sky/tools/flutter_gdb @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/install_framework_headers.py b/sky/tools/install_framework_headers.py index a746ff90b0e7e..1defe100b1ea9 100755 --- a/sky/tools/install_framework_headers.py +++ b/sky/tools/install_framework_headers.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/objcopy.py b/sky/tools/objcopy.py index b8da36d43b8e3..ed2256bc5f209 100755 --- a/sky/tools/objcopy.py +++ b/sky/tools/objcopy.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/roll/patch.py b/sky/tools/roll/patch.py index f08b610e31601..f7242b4d92489 100755 --- a/sky/tools/roll/patch.py +++ b/sky/tools/roll/patch.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/roll/roll.py b/sky/tools/roll/roll.py index c4d322cb9cebb..b526c6b7c7318 100755 --- a/sky/tools/roll/roll.py +++ b/sky/tools/roll/roll.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/sky/tools/roll/utils.py b/sky/tools/roll/utils.py index c14732e34d12d..c5008eec30b33 100755 --- a/sky/tools/roll/utils.py +++ b/sky/tools/roll/utils.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/testing/rules/run_gradle.py b/testing/rules/run_gradle.py index 41bb007ea6cc9..cdde9a818e3a4 100644 --- a/testing/rules/run_gradle.py +++ b/testing/rules/run_gradle.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/testing/run_tests.py b/testing/run_tests.py index 50eea3b983f7a..5881e161b1d2d 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/android_illegal_imports.py b/tools/android_illegal_imports.py index e07573f141f92..6c292bea12401 100644 --- a/tools/android_illegal_imports.py +++ b/tools/android_illegal_imports.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/androidx/generate_pom_file.py b/tools/androidx/generate_pom_file.py index b2cd3deac37de..10fe63338c739 100644 --- a/tools/androidx/generate_pom_file.py +++ b/tools/androidx/generate_pom_file.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2019 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/dia_dll.py b/tools/dia_dll.py index 9366349878a9b..010ed4f1eeb2c 100644 --- a/tools/dia_dll.py +++ b/tools/dia_dll.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright (c) 2012 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. diff --git a/tools/font-subset/test.py b/tools/font-subset/test.py index d97aa4f9f08c4..977dec352be44 100755 --- a/tools/font-subset/test.py +++ b/tools/font-subset/test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/build_fuchsia_artifacts.py b/tools/fuchsia/build_fuchsia_artifacts.py index a954230bc4c27..861b6eef819d0 100755 --- a/tools/fuchsia/build_fuchsia_artifacts.py +++ b/tools/fuchsia/build_fuchsia_artifacts.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/compile_cml.py b/tools/fuchsia/compile_cml.py index 36acd818a43a8..ae058d2f53946 100755 --- a/tools/fuchsia/compile_cml.py +++ b/tools/fuchsia/compile_cml.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/copy_debug_symbols.py b/tools/fuchsia/copy_debug_symbols.py index 4d4cdaef686ca..cc415eb59d420 100755 --- a/tools/fuchsia/copy_debug_symbols.py +++ b/tools/fuchsia/copy_debug_symbols.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/copy_path.py b/tools/fuchsia/copy_path.py index 1dd4693237754..335c262ce3dee 100755 --- a/tools/fuchsia/copy_path.py +++ b/tools/fuchsia/copy_path.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/gather_flutter_runner_artifacts.py b/tools/fuchsia/gather_flutter_runner_artifacts.py index b337deeaddfd2..e2d67ab8becf6 100755 --- a/tools/fuchsia/gather_flutter_runner_artifacts.py +++ b/tools/fuchsia/gather_flutter_runner_artifacts.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/gen_package.py b/tools/fuchsia/gen_package.py index 873356f7c67fd..c9bd85b74aadb 100755 --- a/tools/fuchsia/gen_package.py +++ b/tools/fuchsia/gen_package.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/gen_repo.py b/tools/fuchsia/gen_repo.py index 84a72603ce225..604fe33cb2367 100755 --- a/tools/fuchsia/gen_repo.py +++ b/tools/fuchsia/gen_repo.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/interpolate_test_suite.py b/tools/fuchsia/interpolate_test_suite.py index 0e484ded024b5..3e61f6520fb38 100755 --- a/tools/fuchsia/interpolate_test_suite.py +++ b/tools/fuchsia/interpolate_test_suite.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/make_build_info.py b/tools/fuchsia/make_build_info.py index 4e79f8512bedd..d4565702a199c 100644 --- a/tools/fuchsia/make_build_info.py +++ b/tools/fuchsia/make_build_info.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/merge_and_upload_debug_symbols.py b/tools/fuchsia/merge_and_upload_debug_symbols.py index 6b5786d2079b2..964358671e25f 100755 --- a/tools/fuchsia/merge_and_upload_debug_symbols.py +++ b/tools/fuchsia/merge_and_upload_debug_symbols.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/fuchsia/parse_manifest.py b/tools/fuchsia/parse_manifest.py index bb7e4917e38eb..3863e6bae3199 100755 --- a/tools/fuchsia/parse_manifest.py +++ b/tools/fuchsia/parse_manifest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tools/gen_android_buildconfig.py b/tools/gen_android_buildconfig.py index f54c8723e914c..485d8f99987af 100644 --- a/tools/gen_android_buildconfig.py +++ b/tools/gen_android_buildconfig.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/gen_javadoc.py b/tools/gen_javadoc.py index f19d2dda40094..b91096f79e3e4 100755 --- a/tools/gen_javadoc.py +++ b/tools/gen_javadoc.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/licenses/lib/main.dart b/tools/licenses/lib/main.dart index 2122f20b9e56c..3adbbf6a36163 100644 --- a/tools/licenses/lib/main.dart +++ b/tools/licenses/lib/main.dart @@ -77,7 +77,7 @@ class _RepositorySourceFile extends _RepositoryLicensedFile { fs.TextFile get ioTextFile => super.io as fs.TextFile; - static final RegExp _hashBangPattern = RegExp(r'^#! *(?:/bin/sh|/bin/bash|/usr/bin/env +(?:python|bash))\b'); + static final RegExp _hashBangPattern = RegExp(r'^#! *(?:/bin/sh|/bin/bash|/usr/bin/env +(?:python|python3|bash))\b'); @override bool get isShellScript { From a5ee1027a7881ddb44d9bbcb4485680318bd011e Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 30 Jul 2021 19:29:07 -0700 Subject: [PATCH 2/2] Python 3 cleanup Brackets on print statements and wrapping map iteration in lists etc. --- build/copy_info_plist.py | 6 +++--- build/dart/tools/dart_pkg.py | 4 ++-- build/generate_coverage.py | 2 +- build/git_revision.py | 6 +++--- sky/tools/create_xcframework.py | 6 +++--- sky/tools/flutter_gdb | 6 +++--- sky/tools/roll/patch.py | 4 ++-- sky/tools/roll/roll.py | 12 ++++++------ testing/run_tests.py | 18 +++++++++--------- .../fuchsia/gather_flutter_runner_artifacts.py | 2 +- .../fuchsia/merge_and_upload_debug_symbols.py | 2 +- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/build/copy_info_plist.py b/build/copy_info_plist.py index 031975b37a8b4..f393039121eb2 100644 --- a/build/copy_info_plist.py +++ b/build/copy_info_plist.py @@ -13,9 +13,9 @@ usage: copy_info_plist.py --bitcode= """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function + + + import subprocess import sys diff --git a/build/dart/tools/dart_pkg.py b/build/dart/tools/dart_pkg.py index 15c29cd7bace9..09c7403eab757 100755 --- a/build/dart/tools/dart_pkg.py +++ b/build/dart/tools/dart_pkg.py @@ -81,7 +81,7 @@ def copy(from_root, to_root, filter_func=None): os.makedirs(to_dir) shutil.copy(from_path, to_path) - dirs[:] = filter(wrapped_filter, dirs) + dirs[:] = list(filter(wrapped_filter, dirs)) def copy_or_link(from_root, to_root, filter_func=None): @@ -114,7 +114,7 @@ def list_files(from_root, filter_func=None): for name in filter(wrapped_filter, files): path = os.path.join(root, name) file_list.append(path) - dirs[:] = filter(wrapped_filter, dirs) + dirs[:] = list(filter(wrapped_filter, dirs)) return file_list diff --git a/build/generate_coverage.py b/build/generate_coverage.py index ae7099f47a3fe..4beecddb068f5 100755 --- a/build/generate_coverage.py +++ b/build/generate_coverage.py @@ -84,7 +84,7 @@ def main(): RemoveIfExists(raw_profile) - print "Running test %s to gather profile." % os.path.basename(absolute_test_path) + print("Running test %s to gather profile." % os.path.basename(absolute_test_path)) test_command = [absolute_test_path] diff --git a/build/git_revision.py b/build/git_revision.py index 778d7e70c7d60..c724f224801b6 100755 --- a/build/git_revision.py +++ b/build/git_revision.py @@ -5,9 +5,9 @@ # found in the LICENSE file. """Get the Git HEAD revision of a specified Git repository.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function + + + import sys import subprocess diff --git a/sky/tools/create_xcframework.py b/sky/tools/create_xcframework.py index 9bd0609457dbe..774a3ef90d8c5 100755 --- a/sky/tools/create_xcframework.py +++ b/sky/tools/create_xcframework.py @@ -4,9 +4,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function + + + import argparse import errno diff --git a/sky/tools/flutter_gdb b/sky/tools/flutter_gdb index 273952f415f78..fd7fec060e128 100755 --- a/sky/tools/flutter_gdb +++ b/sky/tools/flutter_gdb @@ -40,7 +40,7 @@ def _find_package_pid(adb_path, package): ps_output = subprocess.check_output([adb_path, 'shell', 'ps']) ps_match = re.search('^\S+\s+(\d+).*\s%s' % package, ps_output, re.MULTILINE) if not ps_match: - print 'Unable to find pid for package %s on device' % package + print('Unable to find pid for package %s on device' % package) return None return int(ps_match.group(1)) @@ -115,7 +115,7 @@ class GdbClient(object): dev_null = open(os.devnull, 'w') for lib, local_path in sorted(device_libs): - print 'Copying %s' % lib + print('Copying %s' % lib) local_path = os.path.join(GdbClient.SYSTEM_LIBS_PATH, local_path) if not os.path.exists(os.path.dirname(local_path)): os.makedirs(os.path.dirname(local_path)) @@ -145,7 +145,7 @@ class GdbClient(object): debug_out_path = os.path.join(flutter_root, 'out/%s' % local_engine) if not os.path.exists(os.path.join(debug_out_path, 'libflutter.so')): - print 'Unable to find libflutter.so. Make sure you have completed a %s build' % local_engine + print('Unable to find libflutter.so. Make sure you have completed a %s build' % local_engine) return 1 eval_commands = [] diff --git a/sky/tools/roll/patch.py b/sky/tools/roll/patch.py index f7242b4d92489..1ffc6a88aae1e 100755 --- a/sky/tools/roll/patch.py +++ b/sky/tools/roll/patch.py @@ -34,10 +34,10 @@ def patch(dest_dir, relative_patches_dir=os.curdir): os.chdir(dest_dir) for p in utils.find(["*.patch"], patches_dir): - print "applying patch %s" % os.path.basename(p) + print("applying patch %s" % os.path.basename(p)) try: utils.system(["git", "apply", p]) utils.commit("applied patch %s" % os.path.basename(p)) except subprocess.CalledProcessError: - print "ERROR: patch %s failed to apply" % os.path.basename(p) + print("ERROR: patch %s failed to apply" % os.path.basename(p)) raise diff --git a/sky/tools/roll/roll.py b/sky/tools/roll/roll.py index b526c6b7c7318..a4d03aabdc2d2 100755 --- a/sky/tools/roll/roll.py +++ b/sky/tools/roll/roll.py @@ -9,7 +9,7 @@ import os import subprocess import sys -import urllib2 +import urllib.request, urllib.error, urllib.parse from utils import commit from utils import system import patch @@ -97,12 +97,12 @@ def rev(source_dir, dest_dir, dirs_to_rev, name, revision_file=None): else: d = dir_to_rev file_subset = None - print "removing directory %s" % d + print("removing directory %s" % d) try: system(["git", "rm", "-r", d], cwd=dest_dir) except subprocess.CalledProcessError: - print "Could not remove %s" % d - print "cloning directory %s" % d + print("Could not remove %s" % d) + print("cloning directory %s" % d) if file_subset is None: files = system(["git", "ls-files", d], cwd=source_dir).splitlines() @@ -152,8 +152,8 @@ def main(): try: patch.patch_and_filter(dest_dir, os.path.join('patches', 'chromium')) except subprocess.CalledProcessError: - print "ERROR: Roll failed due to a patch not applying" - print "Fix the patch to apply, commit the result, and re-run this script" + print("ERROR: Roll failed due to a patch not applying") + print("Fix the patch to apply, commit the result, and re-run this script") return 1 return 0 diff --git a/testing/run_tests.py b/testing/run_tests.py index 5881e161b1d2d..9f2553a9705d9 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -28,17 +28,17 @@ def PrintDivider(char='='): - print '\n' - for _ in xrange(4): - print(''.join([char for _ in xrange(80)])) - print '\n' + print('\n') + for _ in range(4): + print(''.join([char for _ in range(80)])) + print('\n') def RunCmd(cmd, forbidden_output=[], expect_failure=False, env=None, **kwargs): command_string = ' '.join(cmd) PrintDivider('>') - print 'Running command "%s"' % command_string + print('Running command "%s"' % command_string) start_time = time.time() stdout_pipe = sys.stdout if not forbidden_output else subprocess.PIPE @@ -71,7 +71,7 @@ def RunCmd(cmd, forbidden_output=[], expect_failure=False, env=None, **kwargs): raise Exception('command "%s" contained forbidden string %s' % (command_string, forbidden_string)) PrintDivider('<') - print 'Command run successfully in %.2f seconds: %s' % (end_time - start_time, command_string) + print('Command run successfully in %.2f seconds: %s' % (end_time - start_time, command_string)) def IsMac(): @@ -147,7 +147,7 @@ def RunEngineExecutable(build_dir, executable_name, filter, flags=[], core_path = os.path.join(cwd, 'core') if luci_test_outputs_path and os.path.exists(core_path) and os.path.exists(unstripped_exe): dump_path = os.path.join(luci_test_outputs_path, '%s_%s.txt' % (executable_name, sys.platform)) - print 'Writing core dump analysis to %s' % dump_path + print('Writing core dump analysis to %s' % dump_path) subprocess.call([ os.path.join(buildroot_dir, 'flutter', 'testing', 'analyze_core_dump.sh'), buildroot_dir, unstripped_exe, core_path, dump_path, @@ -342,12 +342,12 @@ def RunJavaTests(filter, android_variant='android_debug_unopt'): EnsureJavaTestsAreBuilt(android_out_dir) embedding_deps_dir = os.path.join(buildroot_dir, 'third_party', 'android_embedding_dependencies', 'lib') - classpath = map(str, [ + classpath = list(map(str, [ os.path.join(buildroot_dir, 'third_party', 'android_tools', 'sdk', 'platforms', 'android-30', 'android.jar'), os.path.join(embedding_deps_dir, '*'), # Wildcard for all jars in the directory os.path.join(android_out_dir, 'flutter.jar'), os.path.join(android_out_dir, 'robolectric_tests.jar') - ]) + ])) test_class = filter if filter else 'io.flutter.FlutterTestSuite' command = [ diff --git a/tools/fuchsia/gather_flutter_runner_artifacts.py b/tools/fuchsia/gather_flutter_runner_artifacts.py index e2d67ab8becf6..942d02fed14f8 100755 --- a/tools/fuchsia/gather_flutter_runner_artifacts.py +++ b/tools/fuchsia/gather_flutter_runner_artifacts.py @@ -58,7 +58,7 @@ def GatherArtifacts(src_root, dst_root, create_meta_package=True): else: shutil.rmtree(dst_root) - for src_rel, dst_rel in _ARTIFACT_PATH_TO_DST.iteritems(): + for src_rel, dst_rel in _ARTIFACT_PATH_TO_DST.items(): src_full = os.path.join(src_root, src_rel) dst_full = os.path.join(dst_root, dst_rel) if not os.path.exists(src_full): diff --git a/tools/fuchsia/merge_and_upload_debug_symbols.py b/tools/fuchsia/merge_and_upload_debug_symbols.py index 964358671e25f..e1c71b6eb9883 100755 --- a/tools/fuchsia/merge_and_upload_debug_symbols.py +++ b/tools/fuchsia/merge_and_upload_debug_symbols.py @@ -167,7 +167,7 @@ def main(): out_dir = args.out_dir if os.path.exists(out_dir): - print 'Directory: %s is not empty, deleting it.' % out_dir + print('Directory: %s is not empty, deleting it.' % out_dir) shutil.rmtree(out_dir) os.makedirs(out_dir)