[release] Clean up python2 code

No-Try: true
Bug: chromium:1292013
Change-Id: Id9966157d28528b28e820d328b4941287a310209
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3521790
Reviewed-by: Liviu Rau <liviurau@chromium.org>
Auto-Submit: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79476}
This commit is contained in:
Michael Achenbach 2022-03-15 11:43:19 +01:00 committed by V8 LUCI CQ
parent a875615c69
commit 6d1825e21a
11 changed files with 15 additions and 56 deletions

View File

@ -9,7 +9,8 @@ USE_PYTHON3 = True
def _CommonChecks(input_api, output_api): def _CommonChecks(input_api, output_api):
tests = input_api.canned_checks.GetUnitTestsInDirectory( tests = input_api.canned_checks.GetUnitTestsInDirectory(
input_api, output_api, '.', files_to_check=['test_scripts.py$']) input_api, output_api, '.', files_to_check=['test_scripts.py$'],
run_on_python2=False)
return input_api.RunTests(tests) return input_api.RunTests(tests)
def CheckChangeOnUpload(input_api, output_api): def CheckChangeOnUpload(input_api, output_api):

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2013 the V8 project authors. All rights reserved. # Copyright 2013 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
@ -26,9 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
import json import json
import os import os

View File

@ -3,9 +3,6 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
import os import os
import sys import sys

View File

@ -1,11 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved. # Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
import sys import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2013 the V8 project authors. All rights reserved. # Copyright 2013 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
@ -26,9 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
import datetime import datetime
from distutils.version import LooseVersion from distutils.version import LooseVersion
@ -47,14 +44,8 @@ import urllib
from git_recipes import GitRecipesMixin from git_recipes import GitRecipesMixin
from git_recipes import GitFailedException from git_recipes import GitFailedException
PYTHON3 = sys.version_info >= (3, 0) import http.client as httplib
import urllib.request as urllib2
if PYTHON3:
import http.client as httplib
import urllib.request as urllib2
else:
import httplib
import urllib2
DAY_IN_SECONDS = 24 * 60 * 60 DAY_IN_SECONDS = 24 * 60 * 60
@ -76,10 +67,6 @@ new_path = path_to_depot_tools + os.pathsep + os.environ.get('PATH')
os.environ['PATH'] = new_path os.environ['PATH'] = new_path
def maybe_decode(obj):
return obj.decode('utf-8') if PYTHON3 else obj
def TextToFile(text, file_name): def TextToFile(text, file_name):
with open(file_name, "w") as f: with open(file_name, "w") as f:
f.write(text) f.write(text)
@ -116,7 +103,7 @@ def Command(cmd, args="", prefix="", pipe=True, cwd=None):
sys.stdout.flush() sys.stdout.flush()
try: try:
if pipe: if pipe:
return maybe_decode(subprocess.check_output(cmd_line, shell=True, cwd=cwd)) return subprocess.check_output(cmd_line, shell=True, cwd=cwd).decode('utf-8')
else: else:
return subprocess.check_call(cmd_line, shell=True, cwd=cwd) return subprocess.check_call(cmd_line, shell=True, cwd=cwd)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:

View File

@ -1,11 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2015 the V8 project authors. All rights reserved. # Copyright 2015 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
import os import os
import sys import sys
@ -13,12 +10,7 @@ import tempfile
from common_includes import * from common_includes import *
PYTHON3 = sys.version_info >= (3, 0) import urllib.request as urllib2
if PYTHON3:
import urllib.request as urllib2
else:
import urllib2
class Preparation(Step): class Preparation(Step):

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved. # Copyright 2014 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved. # Copyright 2014 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
@ -26,9 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
from collections import OrderedDict from collections import OrderedDict
import sys import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved. # Copyright 2014 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
@ -26,9 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# for py2/py3 compatibility
from __future__ import print_function
import argparse import argparse
from collections import OrderedDict from collections import OrderedDict
import sys import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved. # Copyright 2014 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
@ -29,9 +29,6 @@
# Wraps test execution with a coverage analysis. To get the best speed, the # Wraps test execution with a coverage analysis. To get the best speed, the
# native python coverage version >= 3.7.1 should be installed. # native python coverage version >= 3.7.1 should be installed.
# for py2/py3 compatibility
from __future__ import print_function
import coverage import coverage
import os import os
import unittest import unittest

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright 2013 the V8 project authors. All rights reserved. # Copyright 2013 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
@ -26,9 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# for py2/py3 compatibility
from __future__ import print_function
import json import json
import os import os
import shutil import shutil