mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-10-30 14:44:09 +00:00
I lint, therefore I am
Implement fixes for the most recent pylint version.
This commit is contained in:
committed by
Marc Bonnici
parent
0e0d4e0ff0
commit
c410d2e1a1
@@ -72,10 +72,9 @@ class LogcatParser(object):
|
||||
tid = int(parts.pop(0))
|
||||
level = LogcatLogLevel.levels[log_level_map.index(parts.pop(0))]
|
||||
tag = (parts.pop(0) if parts else '').strip()
|
||||
except Exception as e:
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
message = 'Invalid metadata for line:\n\t{}\n\tgot: "{}"'
|
||||
logger.warning(message.format(line, e))
|
||||
return None
|
||||
|
||||
return LogcatEvent(timestamp, pid, tid, level, tag, message)
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ class ParallelStats(object):
|
||||
running_time_pc *= 100
|
||||
else:
|
||||
running_time_pc = 0
|
||||
precision = self.use_ratios and 3 or 1
|
||||
precision = 3 if self.use_ratios else 1
|
||||
fmt = '{{:.{}f}}'.format(precision)
|
||||
report.add([cluster, n,
|
||||
fmt.format(time),
|
||||
@@ -524,7 +524,7 @@ class PowerStateStats(object):
|
||||
time_pc *= 100
|
||||
state_stats[state][cpu] = time_pc
|
||||
|
||||
precision = self.use_ratios and 3 or 1
|
||||
precision = 3 if self.use_ratios else 1
|
||||
return PowerStateStatsReport(self.filepath, state_stats, self.core_names, precision)
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ def build_idle_state_map(cpus):
|
||||
return idle_state_map
|
||||
|
||||
|
||||
def report_power_stats(trace_file, cpus, output_basedir, use_ratios=False, no_idle=None,
|
||||
def report_power_stats(trace_file, cpus, output_basedir, use_ratios=False, no_idle=None, # pylint: disable=too-many-locals
|
||||
split_wfi_states=False):
|
||||
"""
|
||||
Process trace-cmd output to generate timelines and statistics of CPU power
|
||||
@@ -704,4 +704,3 @@ def report_power_stats(trace_file, cpus, output_basedir, use_ratios=False, no_id
|
||||
report.write()
|
||||
reports[report.name] = report
|
||||
return reports
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ def log_error(e, logger, critical=False):
|
||||
old_level = set_indent_level(0)
|
||||
logger.info('Got CTRL-C. Aborting.')
|
||||
set_indent_level(old_level)
|
||||
elif isinstance(e, WAError) or isinstance(e, DevlibError):
|
||||
elif isinstance(e, (WAError, DevlibError)):
|
||||
log_func(str(e))
|
||||
elif isinstance(e, subprocess.CalledProcessError):
|
||||
tb = get_traceback()
|
||||
|
||||
@@ -31,11 +31,13 @@ import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
from datetime import datetime, timedelta
|
||||
from functools import reduce
|
||||
from operator import mul
|
||||
if sys.version_info[0] == 3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from io import BytesIO as StringIO
|
||||
# pylint: disable=wrong-import-position,unused-import
|
||||
from itertools import chain, cycle
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
@@ -257,13 +259,13 @@ def format_duration(seconds, sep=' ', order=['day', 'hour', 'minute', 'second'])
|
||||
result = []
|
||||
for item in order:
|
||||
value = getattr(dt, item, None)
|
||||
if item is 'day':
|
||||
if item == 'day':
|
||||
value -= 1
|
||||
if not value:
|
||||
continue
|
||||
suffix = '' if value == 1 else 's'
|
||||
result.append('{} {}{}'.format(value, item, suffix))
|
||||
return result and sep.join(result) or 'N/A'
|
||||
return sep.join(result) if result else 'N/A'
|
||||
|
||||
|
||||
def get_article(word):
|
||||
|
||||
@@ -66,7 +66,7 @@ import yaml as _yaml
|
||||
import dateutil.parser
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
from past.builtins import basestring
|
||||
from past.builtins import basestring # pylint: disable=wrong-import-order
|
||||
|
||||
from wa.framework.exception import SerializerSyntaxError
|
||||
from wa.utils.misc import isiterable
|
||||
@@ -104,7 +104,7 @@ POD_TYPES = [
|
||||
|
||||
class WAJSONEncoder(_json.JSONEncoder):
|
||||
|
||||
def default(self, obj): # pylint: disable=method-hidden
|
||||
def default(self, obj): # pylint: disable=method-hidden,arguments-differ
|
||||
if isinstance(obj, regex_type):
|
||||
return 'REGEX:{}:{}'.format(obj.flags, obj.pattern)
|
||||
elif isinstance(obj, datetime):
|
||||
@@ -119,7 +119,7 @@ class WAJSONEncoder(_json.JSONEncoder):
|
||||
|
||||
class WAJSONDecoder(_json.JSONDecoder):
|
||||
|
||||
def decode(self, s, **kwargs):
|
||||
def decode(self, s, **kwargs): # pylint: disable=arguments-differ
|
||||
d = _json.JSONDecoder.decode(self, s, **kwargs)
|
||||
|
||||
def try_parse_object(v):
|
||||
|
||||
@@ -323,7 +323,7 @@ class TraceCmdParser(object):
|
||||
continue
|
||||
|
||||
body_parser = EVENT_PARSER_MAP.get(event_name, default_body_parser)
|
||||
if isinstance(body_parser, str) or isinstance(body_parser, re._pattern_type): # pylint: disable=protected-access
|
||||
if isinstance(body_parser, (str, re._pattern_type)): # pylint: disable=protected-access
|
||||
body_parser = regex_body_parser(body_parser)
|
||||
yield TraceCmdEvent(parser=body_parser, **match.groupdict())
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ if sys.version_info[0] == 3:
|
||||
from past.builtins import basestring # pylint: disable=redefined-builtin
|
||||
long = int
|
||||
else:
|
||||
from urllib import quote, unquote
|
||||
from urllib import quote, unquote # pylint: disable=no-name-in-module
|
||||
# pylint: disable=wrong-import-position
|
||||
from collections import defaultdict, MutableMapping
|
||||
from copy import copy
|
||||
@@ -325,7 +325,7 @@ class prioritylist(object):
|
||||
def _delete(self, priority, priority_index):
|
||||
del self.elements[priority][priority_index]
|
||||
self.size -= 1
|
||||
if len(self.elements[priority]) == 0:
|
||||
if not self.elements[priority]:
|
||||
self.priorities.remove(priority)
|
||||
self._cached_elements = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user