diff options
author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2020-10-27 16:21:18 +0100 |
---|---|---|
committer | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2020-10-27 16:38:07 +0000 |
commit | 844f1cc2541fe7213ebf2d72039ef28a04e200b4 (patch) | |
tree | aa13653009c1669952c5f64e5d668cfdc26b8a86 /build_scripts/utils.py | |
parent | 07b74c8fde23db33d55b17b08d1d81e1f83b3291 (diff) |
build_scripts: remove references to python 2
* Removing all the special cases for Python 2.7
* Removing Python >=3 conditions
* Keeping Python 3.6+ as the allowed Python
Change-Id: Ie48cafe952ae7a11bea997da2a35e7df5fea9a44
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r-- | build_scripts/utils.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 220d32efe..54b181399 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -48,11 +48,7 @@ import fnmatch import itertools import glob -# There is no urllib.request in Python2 -try: - import urllib.request as urllib -except ImportError: - import urllib +import urllib.request as urllib import distutils.log as log from distutils.errors import DistutilsSetupError @@ -376,7 +372,7 @@ def run_process_output(args, initial_env=None): stdout=subprocess.PIPE).stdout result = [] for raw_line in std_out.readlines(): - line = raw_line if sys.version_info >= (3,) else raw_line.decode('utf-8') + line = raw_line result.append(line.rstrip()) std_out.close() return result @@ -439,9 +435,8 @@ def get_environment_from_batch_command(env_cmd, initial=None): proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial) # parse the output sent to stdout lines = proc.stdout - if sys.version_info[0] > 2: - # make sure the lines are strings - lines = map(lambda s: s.decode(), lines) + # make sure the lines are strings + lines = map(lambda s: s.decode(), lines) # consume whatever output occurs until the tag is reached consume(itertools.takewhile(lambda l: tag not in l, lines)) # define a way to handle each KEY=VALUE line @@ -476,8 +471,6 @@ def back_tick(cmd, ret_err=False): Run command `cmd`, return stdout, or stdout, stderr, return_code if `ret_err` is True. - Roughly equivalent to ``check_output`` in Python 2.7 - Parameters ---------- cmd : str |