mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 02:01:16 +00:00
wa/utils: Fix pylint errors
This commit is contained in:
parent
1550e9a788
commit
185bff9029
@ -57,7 +57,7 @@ class LogcatParser(object):
|
|||||||
if event:
|
if event:
|
||||||
yield event
|
yield event
|
||||||
|
|
||||||
def parse_line(self, line):
|
def parse_line(self, line): #pylint: disable=no-self-use
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line or line.startswith('-') or ': ' not in line:
|
if not line or line.startswith('-') or ': ' not in line:
|
||||||
return None
|
return None
|
||||||
|
@ -564,7 +564,7 @@ class CpuUtilizationTimeline(object):
|
|||||||
|
|
||||||
def update(self, timestamp, core_states): # NOQA
|
def update(self, timestamp, core_states): # NOQA
|
||||||
row = [timestamp]
|
row = [timestamp]
|
||||||
for core, [idle_state, frequency] in enumerate(core_states):
|
for core, [_, frequency] in enumerate(core_states):
|
||||||
if frequency is not None:
|
if frequency is not None:
|
||||||
frequency /= float(self._max_freq_list[core])
|
frequency /= float(self._max_freq_list[core])
|
||||||
row.append(frequency)
|
row.append(frequency)
|
||||||
@ -584,7 +584,7 @@ def build_idle_state_map(cpus):
|
|||||||
for cpu_idx, cpu in enumerate(cpus):
|
for cpu_idx, cpu in enumerate(cpus):
|
||||||
related_cpus = set(cpu.cpufreq.related_cpus) - set([cpu_idx])
|
related_cpus = set(cpu.cpufreq.related_cpus) - set([cpu_idx])
|
||||||
first_cluster_state = cpu.cpuidle.num_states - 1
|
first_cluster_state = cpu.cpuidle.num_states - 1
|
||||||
for state_idx, state in enumerate(cpu.cpuidle.states):
|
for state_idx, _ in enumerate(cpu.cpuidle.states):
|
||||||
if state_idx < first_cluster_state:
|
if state_idx < first_cluster_state:
|
||||||
idle_state_map[(cpu_idx, state_idx)] = []
|
idle_state_map[(cpu_idx, state_idx)] = []
|
||||||
else:
|
else:
|
||||||
|
@ -17,8 +17,8 @@ import os
|
|||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
#pyline disable=redefined-builtin
|
|
||||||
from builtins import zip
|
from builtins import zip #pyline disable=redefined-builtin
|
||||||
from future.moves.itertools import zip_longest
|
from future.moves.itertools import zip_longest
|
||||||
|
|
||||||
from wa.utils.misc import diff_tokens, write_table
|
from wa.utils.misc import diff_tokens, write_table
|
||||||
@ -70,7 +70,7 @@ def diff_interrupt_files(before, after, result): # pylint: disable=R0914
|
|||||||
|
|
||||||
def diff_sysfs_dirs(before, after, result): # pylint: disable=R0914
|
def diff_sysfs_dirs(before, after, result): # pylint: disable=R0914
|
||||||
before_files = []
|
before_files = []
|
||||||
for root, dirs, files in os.walk(before):
|
for root, _, files in os.walk(before):
|
||||||
before_files.extend([os.path.join(root, f) for f in files])
|
before_files.extend([os.path.join(root, f) for f in files])
|
||||||
before_files = list(filter(os.path.isfile, before_files))
|
before_files = list(filter(os.path.isfile, before_files))
|
||||||
files = [os.path.relpath(f, before) for f in before_files]
|
files = [os.path.relpath(f, before) for f in before_files]
|
||||||
|
@ -49,7 +49,7 @@ _indent_width = 4
|
|||||||
_console_handler = None
|
_console_handler = None
|
||||||
_init_handler = None
|
_init_handler = None
|
||||||
|
|
||||||
|
#pylint: disable=global-statement
|
||||||
def init(verbosity=logging.INFO, color=True, indent_with=4,
|
def init(verbosity=logging.INFO, color=True, indent_with=4,
|
||||||
regular_fmt='%(levelname)-8s %(message)s',
|
regular_fmt='%(levelname)-8s %(message)s',
|
||||||
verbose_fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s',
|
verbose_fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s',
|
||||||
@ -95,6 +95,7 @@ def set_level(level):
|
|||||||
_console_handler.setLevel(level)
|
_console_handler.setLevel(level)
|
||||||
|
|
||||||
|
|
||||||
|
#pylint: disable=global-statement
|
||||||
def add_file(filepath, level=logging.DEBUG,
|
def add_file(filepath, level=logging.DEBUG,
|
||||||
fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s'):
|
fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s'):
|
||||||
global _init_handler
|
global _init_handler
|
||||||
@ -139,11 +140,13 @@ def __disable_logger(logger):
|
|||||||
logger.propagate = False
|
logger.propagate = False
|
||||||
|
|
||||||
|
|
||||||
|
#pylint: disable=global-statement
|
||||||
def indent():
|
def indent():
|
||||||
global _indent_level
|
global _indent_level
|
||||||
_indent_level += 1
|
_indent_level += 1
|
||||||
|
|
||||||
|
|
||||||
|
#pylint: disable=global-statement
|
||||||
def dedent():
|
def dedent():
|
||||||
global _indent_level
|
global _indent_level
|
||||||
_indent_level -= 1
|
_indent_level -= 1
|
||||||
@ -158,6 +161,7 @@ def indentcontext():
|
|||||||
dedent()
|
dedent()
|
||||||
|
|
||||||
|
|
||||||
|
#pylint: disable=global-statement
|
||||||
def set_indent_level(level):
|
def set_indent_level(level):
|
||||||
global _indent_level
|
global _indent_level
|
||||||
old_level = _indent_level
|
old_level = _indent_level
|
||||||
@ -265,11 +269,11 @@ class LineFormatter(logging.Formatter):
|
|||||||
record.asctime = self.formatTime(record, self.datefmt)
|
record.asctime = self.formatTime(record, self.datefmt)
|
||||||
|
|
||||||
indent_level = getattr(record, 'indent_level', _indent_level)
|
indent_level = getattr(record, 'indent_level', _indent_level)
|
||||||
indent = _indent_width * indent_level
|
cur_indent = _indent_width * indent_level
|
||||||
d = record.__dict__
|
d = record.__dict__
|
||||||
parts = []
|
parts = []
|
||||||
for line in record.message.split('\n'):
|
for line in record.message.split('\n'):
|
||||||
line = ' ' * indent + line
|
line = ' ' * cur_indent + line
|
||||||
d.update({'message': line.strip('\r')})
|
d.update({'message': line.strip('\r')})
|
||||||
parts.append(self._fmt % d)
|
parts.append(self._fmt % d)
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ def categorize(v):
|
|||||||
else:
|
else:
|
||||||
return 'c'
|
return 'c'
|
||||||
|
|
||||||
|
#pylint: disable=too-many-return-statements,too-many-branches
|
||||||
def merge_config_values(base, other):
|
def merge_config_values(base, other):
|
||||||
"""
|
"""
|
||||||
This is used to merge two objects, typically when setting the value of a
|
This is used to merge two objects, typically when setting the value of a
|
||||||
|
@ -65,6 +65,7 @@ from datetime import datetime
|
|||||||
import yaml as _yaml
|
import yaml as _yaml
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
|
#pylint: disable=redefined-builtin
|
||||||
from past.builtins import basestring
|
from past.builtins import basestring
|
||||||
|
|
||||||
from wa.framework.exception import SerializerSyntaxError
|
from wa.framework.exception import SerializerSyntaxError
|
||||||
@ -274,7 +275,7 @@ class python(object):
|
|||||||
exec(s, pod) # pylint: disable=exec-used
|
exec(s, pod) # pylint: disable=exec-used
|
||||||
except SyntaxError as e:
|
except SyntaxError as e:
|
||||||
raise SerializerSyntaxError(e.message, e.lineno)
|
raise SerializerSyntaxError(e.message, e.lineno)
|
||||||
for k in list(pod.keys()):
|
for k in list(pod.keys()): # pylint: disable=consider-iterating-dictionary
|
||||||
if k.startswith('__'):
|
if k.startswith('__'):
|
||||||
del pod[k]
|
del pod[k]
|
||||||
return pod
|
return pod
|
||||||
@ -350,7 +351,7 @@ def _write_pod(pod, wfh, fmt=None):
|
|||||||
|
|
||||||
|
|
||||||
def is_pod(obj):
|
def is_pod(obj):
|
||||||
if type(obj) not in POD_TYPES:
|
if type(obj) not in POD_TYPES: #pylint: disable=unidiomatic-typecheck
|
||||||
return False
|
return False
|
||||||
if hasattr(obj, 'items'):
|
if hasattr(obj, 'items'):
|
||||||
for k, v in obj.items():
|
for k, v in obj.items():
|
||||||
@ -361,6 +362,3 @@ def is_pod(obj):
|
|||||||
if not is_pod(v):
|
if not is_pod(v):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,4 +105,3 @@ def _get_terminal_size_linux():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sizex, sizey = get_terminal_size()
|
sizex, sizey = get_terminal_size()
|
||||||
print('width =', sizex, 'height =', sizey)
|
print('width =', sizex, 'height =', sizey)
|
||||||
|
|
||||||
|
@ -266,6 +266,7 @@ class TraceCmdParser(object):
|
|||||||
by trace-cmd
|
by trace-cmd
|
||||||
"""
|
"""
|
||||||
inside_maked_region = False
|
inside_maked_region = False
|
||||||
|
#pylint: disable=superfluous-parens
|
||||||
filters = [re.compile('^{}$'.format(e)) for e in (self.events or [])]
|
filters = [re.compile('^{}$'.format(e)) for e in (self.events or [])]
|
||||||
filter_markers = self.filter_markers
|
filter_markers = self.filter_markers
|
||||||
if filter_markers and self.check_for_markers:
|
if filter_markers and self.check_for_markers:
|
||||||
|
@ -800,7 +800,7 @@ class cpu_mask(object):
|
|||||||
elif isinstance(cpus, list):
|
elif isinstance(cpus, list):
|
||||||
self._mask = list_to_mask(cpus)
|
self._mask = list_to_mask(cpus)
|
||||||
elif isinstance(cpus, cpu_mask):
|
elif isinstance(cpus, cpu_mask):
|
||||||
self._mask = cpus._mask
|
self._mask = cpus._mask # pylint: disable=protected-access
|
||||||
else:
|
else:
|
||||||
msg = 'Unknown conversion from {} to cpu mask'
|
msg = 'Unknown conversion from {} to cpu mask'
|
||||||
raise ValueError(msg.format(cpus))
|
raise ValueError(msg.format(cpus))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user