mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 12:06:08 +00:00
Remove Python 2 support
Python 2 is long dead and devlib does not support it anymore, so cleanup old Python 2-only code.
This commit is contained in:
parent
28b78a93f1
commit
6fe4bce68d
@ -32,17 +32,11 @@ def transform(mod):
|
|||||||
if b'pylint:' in text[0]:
|
if b'pylint:' in text[0]:
|
||||||
msg = 'pylint directive found on the first line of {}; please move to below copyright header'
|
msg = 'pylint directive found on the first line of {}; please move to below copyright header'
|
||||||
raise RuntimeError(msg.format(mod.name))
|
raise RuntimeError(msg.format(mod.name))
|
||||||
if sys.version_info[0] == 3:
|
char = chr(text[0][0])
|
||||||
char = chr(text[0][0])
|
|
||||||
else:
|
|
||||||
char = text[0][0]
|
|
||||||
if text[0].strip() and char != '#':
|
if text[0].strip() and char != '#':
|
||||||
msg = 'first line of {} is not a comment; is the copyright header missing?'
|
msg = 'first line of {} is not a comment; is the copyright header missing?'
|
||||||
raise RuntimeError(msg.format(mod.name))
|
raise RuntimeError(msg.format(mod.name))
|
||||||
if sys.version_info[0] == 3:
|
text[0] = '# pylint: disable={}'.format(','.join(errors)).encode('utf-8')
|
||||||
text[0] = '# pylint: disable={}'.format(','.join(errors)).encode('utf-8')
|
|
||||||
else:
|
|
||||||
text[0] = '# pylint: disable={}'.format(','.join(errors))
|
|
||||||
mod.file_bytes = b'\n'.join(text)
|
mod.file_bytes = b'\n'.join(text)
|
||||||
|
|
||||||
# This is what *should* happen, but doesn't work.
|
# This is what *should* happen, but doesn't work.
|
||||||
|
@ -25,10 +25,6 @@ from wa.framework.target.manager import TargetManager
|
|||||||
from wa.utils.revent import ReventRecorder
|
from wa.utils.revent import ReventRecorder
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[0] == 3:
|
|
||||||
raw_input = input # pylint: disable=redefined-builtin
|
|
||||||
|
|
||||||
|
|
||||||
class RecordCommand(Command):
|
class RecordCommand(Command):
|
||||||
|
|
||||||
name = 'record'
|
name = 'record'
|
||||||
@ -137,11 +133,11 @@ class RecordCommand(Command):
|
|||||||
def record(self, revent_file, name, output_path):
|
def record(self, revent_file, name, output_path):
|
||||||
msg = 'Press Enter when you are ready to record {}...'
|
msg = 'Press Enter when you are ready to record {}...'
|
||||||
self.logger.info(msg.format(name))
|
self.logger.info(msg.format(name))
|
||||||
raw_input('')
|
input('')
|
||||||
self.revent_recorder.start_record(revent_file)
|
self.revent_recorder.start_record(revent_file)
|
||||||
msg = 'Press Enter when you have finished recording {}...'
|
msg = 'Press Enter when you have finished recording {}...'
|
||||||
self.logger.info(msg.format(name))
|
self.logger.info(msg.format(name))
|
||||||
raw_input('')
|
input('')
|
||||||
self.revent_recorder.stop_record()
|
self.revent_recorder.stop_record()
|
||||||
|
|
||||||
if not os.path.isdir(output_path):
|
if not os.path.isdir(output_path):
|
||||||
|
@ -73,11 +73,8 @@ class ShowCommand(Command):
|
|||||||
|
|
||||||
if which('pandoc'):
|
if which('pandoc'):
|
||||||
p = Popen(['pandoc', '-f', 'rst', '-t', 'man'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
p = Popen(['pandoc', '-f', 'rst', '-t', 'man'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
if sys.version_info[0] == 3:
|
output, _ = p.communicate(rst_output.encode(sys.stdin.encoding))
|
||||||
output, _ = p.communicate(rst_output.encode(sys.stdin.encoding))
|
output = output.decode(sys.stdout.encoding)
|
||||||
output = output.decode(sys.stdout.encoding)
|
|
||||||
else:
|
|
||||||
output, _ = p.communicate(rst_output)
|
|
||||||
|
|
||||||
# Make sure to double escape back slashes
|
# Make sure to double escape back slashes
|
||||||
output = output.replace('\\', '\\\\\\')
|
output = output.replace('\\', '\\\\\\')
|
||||||
|
@ -244,10 +244,7 @@ class Http(ResourceGetter):
|
|||||||
response.status_code,
|
response.status_code,
|
||||||
response.reason))
|
response.reason))
|
||||||
return {}
|
return {}
|
||||||
if sys.version_info[0] == 3:
|
content = response.content.decode('utf-8')
|
||||||
content = response.content.decode('utf-8')
|
|
||||||
else:
|
|
||||||
content = response.content
|
|
||||||
return json.loads(content)
|
return json.loads(content)
|
||||||
|
|
||||||
def download_asset(self, asset, owner_name):
|
def download_asset(self, asset, owner_name):
|
||||||
|
@ -325,10 +325,7 @@ def install(instrument, context):
|
|||||||
if not callable(attr):
|
if not callable(attr):
|
||||||
msg = 'Attribute {} not callable in {}.'
|
msg = 'Attribute {} not callable in {}.'
|
||||||
raise ValueError(msg.format(attr_name, instrument))
|
raise ValueError(msg.format(attr_name, instrument))
|
||||||
if sys.version_info[0] == 3:
|
argspec = inspect.getfullargspec(attr)
|
||||||
argspec = inspect.getfullargspec(attr)
|
|
||||||
else:
|
|
||||||
argspec = inspect.getargspec(attr) # pylint: disable=deprecated-method
|
|
||||||
arg_num = len(argspec.args)
|
arg_num = len(argspec.args)
|
||||||
# Instrument callbacks will be passed exactly two arguments: self
|
# Instrument callbacks will be passed exactly two arguments: self
|
||||||
# (the instrument instance to which the callback is bound) and
|
# (the instrument instance to which the callback is bound) and
|
||||||
|
@ -57,7 +57,4 @@ def get_commit():
|
|||||||
p.wait()
|
p.wait()
|
||||||
if p.returncode:
|
if p.returncode:
|
||||||
return None
|
return None
|
||||||
if sys.version_info[0] == 3 and isinstance(std, bytes):
|
return std[:8].decode(sys.stdout.encoding or 'utf-8')
|
||||||
return std[:8].decode(sys.stdout.encoding or 'utf-8')
|
|
||||||
else:
|
|
||||||
return std[:8]
|
|
||||||
|
@ -41,10 +41,7 @@ from functools import reduce # pylint: disable=redefined-builtin
|
|||||||
from operator import mul
|
from operator import mul
|
||||||
from tempfile import gettempdir, NamedTemporaryFile
|
from tempfile import gettempdir, NamedTemporaryFile
|
||||||
from time import sleep
|
from time import sleep
|
||||||
if sys.version_info[0] == 3:
|
from io import StringIO
|
||||||
from io import StringIO
|
|
||||||
else:
|
|
||||||
from io import BytesIO as StringIO
|
|
||||||
# pylint: disable=wrong-import-position,unused-import
|
# pylint: disable=wrong-import-position,unused-import
|
||||||
from itertools import chain, cycle
|
from itertools import chain, cycle
|
||||||
from distutils.spawn import find_executable # pylint: disable=no-name-in-module, import-error
|
from distutils.spawn import find_executable # pylint: disable=no-name-in-module, import-error
|
||||||
|
@ -31,12 +31,8 @@ import numbers
|
|||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
from bisect import insort
|
from bisect import insort
|
||||||
if sys.version_info[0] == 3:
|
from urllib.parse import quote, unquote # pylint: disable=no-name-in-module, import-error
|
||||||
from urllib.parse import quote, unquote # pylint: disable=no-name-in-module, import-error
|
from past.builtins import basestring # pylint: disable=redefined-builtin
|
||||||
from past.builtins import basestring # pylint: disable=redefined-builtin
|
|
||||||
long = int # pylint: disable=redefined-builtin
|
|
||||||
else:
|
|
||||||
from urllib import quote, unquote # pylint: disable=no-name-in-module
|
|
||||||
# pylint: disable=wrong-import-position
|
# pylint: disable=wrong-import-position
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import MutableMapping
|
from collections.abc import MutableMapping
|
||||||
@ -710,8 +706,6 @@ class ParameterDict(dict):
|
|||||||
prefix = 'f'
|
prefix = 'f'
|
||||||
elif isinstance(obj, bool):
|
elif isinstance(obj, bool):
|
||||||
prefix = 'b'
|
prefix = 'b'
|
||||||
elif isinstance(obj, long):
|
|
||||||
prefix = 'i'
|
|
||||||
elif isinstance(obj, int):
|
elif isinstance(obj, int):
|
||||||
prefix = 'i'
|
prefix = 'i'
|
||||||
elif obj is None:
|
elif obj is None:
|
||||||
@ -792,10 +786,7 @@ class ParameterDict(dict):
|
|||||||
return (key, self._decode(value))
|
return (key, self._decode(value))
|
||||||
|
|
||||||
def iter_encoded_items(self):
|
def iter_encoded_items(self):
|
||||||
if sys.version_info[0] == 3:
|
return dict.items(self)
|
||||||
return dict.items(self)
|
|
||||||
else:
|
|
||||||
return dict.iteritems(self)
|
|
||||||
|
|
||||||
def get_encoded_value(self, name):
|
def get_encoded_value(self, name):
|
||||||
return dict.__getitem__(self, name)
|
return dict.__getitem__(self, name)
|
||||||
|
@ -223,8 +223,7 @@ class JankbenchRunMonitor(threading.Thread):
|
|||||||
ready, _, _ = select.select([proc.stdout, proc.stderr], [], [], 2)
|
ready, _, _ = select.select([proc.stdout, proc.stderr], [], [], 2)
|
||||||
if ready:
|
if ready:
|
||||||
line = ready[0].readline()
|
line = ready[0].readline()
|
||||||
if sys.version_info[0] == 3:
|
line = line.decode(sys.stdout.encoding, 'replace')
|
||||||
line = line.decode(sys.stdout.encoding, 'replace')
|
|
||||||
if self.regex.search(line):
|
if self.regex.search(line):
|
||||||
self.run_ended.set()
|
self.run_ended.set()
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
|
@ -256,10 +256,7 @@ class Meabo(Workload):
|
|||||||
|
|
||||||
outfile = os.path.join(context.output_directory, 'meabo-output.txt')
|
outfile = os.path.join(context.output_directory, 'meabo-output.txt')
|
||||||
with open(outfile, 'wb') as wfh:
|
with open(outfile, 'wb') as wfh:
|
||||||
if sys.version_info[0] == 3:
|
wfh.write(self.output.encode('utf-8'))
|
||||||
wfh.write(self.output.encode('utf-8'))
|
|
||||||
else:
|
|
||||||
wfh.write(self.output)
|
|
||||||
context.add_artifact('meabo-output', outfile, kind='raw')
|
context.add_artifact('meabo-output', outfile, kind='raw')
|
||||||
|
|
||||||
cur_phase = 0
|
cur_phase = 0
|
||||||
|
@ -89,8 +89,7 @@ class PcMark(ApkUiautoWorkload):
|
|||||||
def update_output(self, context):
|
def update_output(self, context):
|
||||||
expected_results = len(self.regex_matches[self.major_version])
|
expected_results = len(self.regex_matches[self.major_version])
|
||||||
zf = zipfile.ZipFile(os.path.join(context.output_directory, self.result_file), 'r').read('Result.xml')
|
zf = zipfile.ZipFile(os.path.join(context.output_directory, self.result_file), 'r').read('Result.xml')
|
||||||
if sys.version_info[0] == 3:
|
zf = zf.decode(sys.stdout.encoding)
|
||||||
zf = zf.decode(sys.stdout.encoding)
|
|
||||||
for line in zf.split('\n'):
|
for line in zf.split('\n'):
|
||||||
for regex in self.regex_matches[self.major_version]:
|
for regex in self.regex_matches[self.major_version]:
|
||||||
match = regex.search(line)
|
match = regex.search(line)
|
||||||
|
Loading…
Reference in New Issue
Block a user