From 18ac3ef222610b5b1146526689b8237278f0560a Mon Sep 17 00:00:00 2001 From: Ravi Mistry Date: Thu, 5 May 2022 20:53:50 +0000 Subject: [PATCH] Revert "[infra] Use Python3 for our Presubmits" This reverts commit 094bcdb9e5dcb2ebe0ef780faf0559ab72b50bac. Reason for revert: Breaking Housekeeper-PerCommit-InfraTests_Linux. The bot will have to be updated as part of this change. Original change's description: > [infra] Use Python3 for our Presubmits > > https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:presubmit_support.py;l=319;drc=443d9135cc33f3156d5fe25ebec33f9adffbab65 > > This also makes any errors from `make train -C infra/bots` > look well formatted because check_output returns a bytestring > in Python3 and when that is printed, the newlines et al are not > rendered correctly. Thus we want the output of check_output > to be encoded to UTF-8. > > Without setting the USE_PYTHON3 = True in PRESUBMIT.py, > it appears that `git cl upload` would try to run our > infra_tests.py in Python2 mode, which does not have > the encoding argument for check_output. > > Apparently cipd_bin_packages/vpython3 does not have the > "six" package installed (but cipd_bin_packages/vpython does) > so I replaced the six.StringIO with io.StringIO, which > is where that is located in Python3. > > Change-Id: Ic8f61bf943531583ba3d110a85260d69bdbf5eb2 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/537677 > Reviewed-by: Ravi Mistry > Reviewed-by: Eric Boren Change-Id: I0becb25d155ce0b0281c25d83662f1b01aee8033 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/537777 Bot-Commit: Rubber Stamper Commit-Queue: Rubber Stamper Auto-Submit: Ravi Mistry --- PRESUBMIT.py | 2 -- infra/bots/infra_tests.py | 2 +- tools/rewrite_includes.py | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 1c246c1226..856478a808 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -27,8 +27,6 @@ SERVICE_ACCOUNT_SUFFIX = [ 'skia-buildbots.google.com', 'skia-swarming-bots', 'skia-public', 'skia-corp.google.com', 'chops-service-accounts']] -USE_PYTHON3 = True - def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): """Checks that files end with at least one \n (LF).""" diff --git a/infra/bots/infra_tests.py b/infra/bots/infra_tests.py index 7d162cb9eb..0e226b546c 100755 --- a/infra/bots/infra_tests.py +++ b/infra/bots/infra_tests.py @@ -21,7 +21,7 @@ SKIA_DIR = os.path.abspath(os.path.join(INFRA_BOTS_DIR, os.pardir, os.pardir)) def test(cmd, cwd): try: - subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT, encoding='utf-8') + subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: return e.output diff --git a/tools/rewrite_includes.py b/tools/rewrite_includes.py index 980c2ef81d..df4474aa1f 100755 --- a/tools/rewrite_includes.py +++ b/tools/rewrite_includes.py @@ -8,9 +8,10 @@ import argparse import os +import six import sys -from io import StringIO +from six import StringIO parser = argparse.ArgumentParser()