From bef8fb40efb4cb7ade51714d9a2d0aaa80e9d75d Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Wed, 9 Dec 2015 15:43:35 +0000 Subject: [PATCH] Updated pylint for v1.5.1 Fixed WA for the latest version of pylint (1.5.1) --- dev_scripts/pylint | 4 +-- extras/pylintrc | 2 +- wlauto/common/android/device.py | 8 ++---- wlauto/common/linux/device.py | 5 ++-- wlauto/core/agenda.py | 3 +-- wlauto/core/device.py | 3 +-- wlauto/core/entry_point.py | 3 +-- wlauto/core/extension_loader.py | 5 ++-- wlauto/devices/android/gem5/__init__.py | 4 +-- .../daq_server/src/daqpower/client.py | 2 +- .../daq_server/src/daqpower/config.py | 3 +-- .../external/daq_server/src/daqpower/daq.py | 6 ++--- .../daq_server/src/daqpower/server.py | 6 ++--- wlauto/instrumentation/daq/__init__.py | 5 ++-- .../instrumentation/energy_model/__init__.py | 2 +- wlauto/instrumentation/fps/__init__.py | 9 +++---- wlauto/instrumentation/perf/__init__.py | 3 +-- wlauto/instrumentation/pmu_logger/__init__.py | 2 +- .../ipynb_exporter/__init__.py | 10 ++++--- wlauto/tests/test_config.py | 5 ++-- wlauto/tests/test_execution.py | 27 ++++++++++--------- wlauto/utils/android.py | 6 +---- wlauto/utils/ipython.py | 3 ++- wlauto/utils/misc.py | 8 +++--- wlauto/utils/netio.py | 5 ++-- wlauto/utils/serial_port.py | 4 +-- wlauto/utils/ssh.py | 3 +-- wlauto/workloads/antutu/__init__.py | 5 ++-- wlauto/workloads/ebizzy/__init__.py | 4 +-- wlauto/workloads/hackbench/__init__.py | 5 ++-- wlauto/workloads/idle/__init__.py | 3 +-- wlauto/workloads/iozone/__init__.py | 10 ++++--- wlauto/workloads/spec2000/__init__.py | 6 +---- wlauto/workloads/stream/__init__.py | 4 +-- wlauto/workloads/telemetry/__init__.py | 5 ++-- 35 files changed, 86 insertions(+), 102 deletions(-) diff --git a/dev_scripts/pylint b/dev_scripts/pylint index 15b088d6..f2a27955 100755 --- a/dev_scripts/pylint +++ b/dev_scripts/pylint @@ -35,10 +35,10 @@ compare_versions() { } pylint_version=$(python -c 'from pylint.__pkginfo__ import version; print version') -compare_versions $pylint_version "1.3.0" +compare_versions $pylint_version "1.5.1" result=$? if [ "$result" == "2" ]; then - echo "ERROR: pylint version must be at least 1.3.0; found $pylint_version" + echo "ERROR: pylint version must be at least 1.5.1; found $pylint_version" exit 1 fi diff --git a/extras/pylintrc b/extras/pylintrc index d0b37d4f..04b2a70f 100644 --- a/extras/pylintrc +++ b/extras/pylintrc @@ -16,7 +16,7 @@ # [MASTER] -profile=no +#profile=no ignore=external diff --git a/wlauto/common/android/device.py b/wlauto/common/android/device.py index 8cddf301..6e83b0bc 100644 --- a/wlauto/common/android/device.py +++ b/wlauto/common/android/device.py @@ -164,7 +164,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 raise DeviceError('Could not boot {} ({}).'.format(self.name, self.adb_name)) while iteration_number < max_iterations: - available = (1 == int('0' + adb_shell(self.adb_name, 'getprop sys.boot_completed', timeout=self.default_timeout))) + available = (int('0' + (adb_shell(self.adb_name, 'getprop sys.boot_completed', timeout=self.default_timeout))) == 1) if available: break else: @@ -331,10 +331,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 self._check_ready() output = adb_shell(self.adb_name, 'if [ -e \'{}\' ]; then echo 1; else echo 0; fi'.format(filepath), timeout=self.default_timeout) - if int(output): - return True - else: - return False + return bool(int(output)) def install(self, filepath, timeout=default_timeout, with_name=None): # pylint: disable=W0221 ext = os.path.splitext(filepath)[1].lower() @@ -739,4 +736,3 @@ class BigLittleDevice(AndroidDevice): # pylint: disable=W0223 parameters = [ Parameter('scheduler', default='hmp', override=True), ] - diff --git a/wlauto/common/linux/device.py b/wlauto/common/linux/device.py index 4b020877..a3957171 100644 --- a/wlauto/common/linux/device.py +++ b/wlauto/common/linux/device.py @@ -248,7 +248,7 @@ class BaseLinuxDevice(Device): # pylint: disable=abstract-method self.execute('echo {} > \'{}\''.format(value, sysfile), check_exit_code=False, as_root=True) if verify: output = self.get_sysfile_value(sysfile) - if not output.strip() == value: # pylint: disable=E1103 + if output.strip() != value: # pylint: disable=E1103 message = 'Could not set the value of {} to {}'.format(sysfile, value) raise DeviceError(message) self._written_sysfiles.append(sysfile) @@ -476,7 +476,7 @@ class BaseLinuxDevice(Device): # pylint: disable=abstract-method if isinstance(on_cpus, basestring): on_cpus = ranges_to_list(on_cpus) if isiterable(on_cpus): - on_cpus = list_to_mask(on_cpus) + on_cpus = list_to_mask(on_cpus) # pylint: disable=redefined-variable-type command = '{} taskset 0x{:x} {}'.format(self.busybox, on_cpus, command) if in_directory: command = 'cd {} && {}'.format(in_directory, command) @@ -807,4 +807,3 @@ class LinuxDevice(BaseLinuxDevice): def ensure_screen_is_on(self): pass # TODO - diff --git a/wlauto/core/agenda.py b/wlauto/core/agenda.py index 91144e74..ccb8bee7 100644 --- a/wlauto/core/agenda.py +++ b/wlauto/core/agenda.py @@ -16,13 +16,12 @@ import os from copy import copy from collections import OrderedDict, defaultdict +import yaml from wlauto.exceptions import ConfigError from wlauto.utils.misc import load_struct_from_yaml, LoadSyntaxError from wlauto.utils.types import counter, reset_counter -import yaml - def get_aliased_param(d, aliases, default=None, pop=True): alias_map = [i for i, a in enumerate(aliases) if a in d] diff --git a/wlauto/core/device.py b/wlauto/core/device.py index 8790965b..9e870b53 100644 --- a/wlauto/core/device.py +++ b/wlauto/core/device.py @@ -303,7 +303,7 @@ class Device(Extension): params = OrderedDict((k.lower(), v) for k, v in params.iteritems() if v is not None) expected_keys = rtp_map.keys() - if not set(params.keys()) <= set(expected_keys): + if not set(params.keys()).issubset(set(expected_keys)): unknown_params = list(set(params.keys()).difference(set(expected_keys))) raise ConfigError('Unknown runtime parameter(s): {}'.format(unknown_params)) @@ -447,4 +447,3 @@ class Device(Extension): except Exception as e: self.ping() raise e - diff --git a/wlauto/core/entry_point.py b/wlauto/core/entry_point.py index e70e4546..4802f4e5 100644 --- a/wlauto/core/entry_point.py +++ b/wlauto/core/entry_point.py @@ -18,6 +18,7 @@ import sys import argparse import logging import subprocess +import warnings from wlauto.core.bootstrap import settings from wlauto.core.extension_loader import ExtensionLoader @@ -28,7 +29,6 @@ from wlauto.utils.cli import init_argument_parser from wlauto.utils.doc import format_body -import warnings warnings.filterwarnings(action='ignore', category=UserWarning, module='zope') @@ -89,4 +89,3 @@ def main(): logging.critical(tb) logging.critical('{}({})'.format(e.__class__.__name__, e)) sys.exit(2) - diff --git a/wlauto/core/extension_loader.py b/wlauto/core/extension_loader.py index 14c2bd89..e9f2fd1c 100644 --- a/wlauto/core/extension_loader.py +++ b/wlauto/core/extension_loader.py @@ -80,7 +80,7 @@ class GlobalParameterAlias(object): other_param.kind != param.kind): message = 'Duplicate global alias {} declared in {} and {} extensions with different types' raise LoaderError(message.format(self.name, ext.name, other_ext.name)) - if not param.name == other_param.name: + if param.name != other_param.name: message = 'Two params {} in {} and {} in {} both declare global alias {}' raise LoaderError(message.format(param.name, ext.name, other_param.name, other_ext.name, self.name)) @@ -320,7 +320,7 @@ class ExtensionLoader(object): if should_skip: continue for fname in files: - if not os.path.splitext(fname)[1].lower() == '.py': + if os.path.splitext(fname)[1].lower() != '.py': continue filepath = os.path.join(root, fname) try: @@ -401,4 +401,3 @@ def _instantiate(cls, args=None, kwargs=None): return cls(*args, **kwargs) except Exception: raise LoaderError('Could not load {}'.format(cls), sys.exc_info()) - diff --git a/wlauto/devices/android/gem5/__init__.py b/wlauto/devices/android/gem5/__init__.py index 5637e07a..d8027173 100644 --- a/wlauto/devices/android/gem5/__init__.py +++ b/wlauto/devices/android/gem5/__init__.py @@ -98,8 +98,8 @@ class Gem5AndroidDevice(BaseGem5Device, AndroidDevice): self.logger.info("Waiting for Android to boot...") while True: try: - booted = (1 == int('0' + self.gem5_shell('getprop sys.boot_completed', check_exit_code=False))) - anim_finished = (1 == int('0' + self.gem5_shell('getprop service.bootanim.exit', check_exit_code=False))) + booted = (int('0' + self.gem5_shell('getprop sys.boot_completed', check_exit_code=False)) == 1) + anim_finished = (int('0' + self.gem5_shell('getprop service.bootanim.exit', check_exit_code=False)) == 1) if booted and anim_finished: break except (DeviceError, ValueError): diff --git a/wlauto/external/daq_server/src/daqpower/client.py b/wlauto/external/daq_server/src/daqpower/client.py index 14fe69d4..80276811 100644 --- a/wlauto/external/daq_server/src/daqpower/client.py +++ b/wlauto/external/daq_server/src/daqpower/client.py @@ -14,7 +14,7 @@ # -# pylint: disable=E1101,E1103 +# pylint: disable=E1101,E1103,wrong-import-position import os import sys diff --git a/wlauto/external/daq_server/src/daqpower/config.py b/wlauto/external/daq_server/src/daqpower/config.py index 86343424..d5b7c885 100644 --- a/wlauto/external/daq_server/src/daqpower/config.py +++ b/wlauto/external/daq_server/src/daqpower/config.py @@ -59,7 +59,7 @@ class DeviceConfiguration(Serializable): def validate(self): if not self.number_of_ports: raise ConfigurationError('No resistor values were specified.') - if not len(self.resistor_values) == len(self.labels): + if len(self.resistor_values) != len(self.labels): message = 'The number of resistors ({}) does not match the number of labels ({})' raise ConfigurationError(message.format(len(self.resistor_values), len(self.labels))) @@ -151,4 +151,3 @@ def get_config_parser(server=True, device=True): parser.add_argument('--host', action=UpdateServerConfig) parser.add_argument('--port', action=UpdateServerConfig, type=int) return parser - diff --git a/wlauto/external/daq_server/src/daqpower/daq.py b/wlauto/external/daq_server/src/daqpower/daq.py index d70399b0..7adae3dd 100644 --- a/wlauto/external/daq_server/src/daqpower/daq.py +++ b/wlauto/external/daq_server/src/daqpower/daq.py @@ -42,7 +42,7 @@ Port 0 :sampling_rate: The rate at which DAQ takes a sample from each channel. """ -# pylint: disable=F0401,E1101,W0621,no-name-in-module +# pylint: disable=F0401,E1101,W0621,no-name-in-module,wrong-import-position,wrong-import-order import os import sys import csv @@ -302,7 +302,7 @@ class DaqRunner(object): if callbacks_supported: self.task = ReadSamplesCallbackTask(config, self.processor) else: - self.task = ReadSamplesThreadedTask(config, self.processor) + self.task = ReadSamplesThreadedTask(config, self.processor) # pylint: disable=redefined-variable-type self.is_running = False def start(self): @@ -334,7 +334,7 @@ if __name__ == '__main__': resistor_values = [0.005] labels = ['PORT_0'] dev_config = DeviceConfig('Dev1', channel_map, resistor_values, 2.5, 0.2, 10000, len(resistor_values), labels) - if not len(sys.argv) == 3: + if len(sys.argv) != 3: print 'Usage: {} OUTDIR DURATION'.format(os.path.basename(__file__)) sys.exit(1) output_directory = sys.argv[1] diff --git a/wlauto/external/daq_server/src/daqpower/server.py b/wlauto/external/daq_server/src/daqpower/server.py index e33a5f9c..5ec9e030 100644 --- a/wlauto/external/daq_server/src/daqpower/server.py +++ b/wlauto/external/daq_server/src/daqpower/server.py @@ -14,7 +14,7 @@ # -# pylint: disable=E1101,W0613 +# pylint: disable=E1101,W0613,wrong-import-position from __future__ import division import os import sys @@ -30,12 +30,12 @@ from twisted.internet.protocol import Factory, Protocol from twisted.internet import reactor, interfaces from twisted.internet.error import ConnectionLost, ConnectionDone - if __name__ == "__main__": # for debugging sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from daqpower import log from daqpower.config import DeviceConfiguration from daqpower.common import DaqServerRequest, DaqServerResponse, Status + try: from daqpower.daq import DaqRunner, list_available_devices, CAN_ENUMERATE_DEVICES __import_error = None @@ -66,7 +66,7 @@ class DummyDaqRunner(object): self.is_running = False def start(self): - import csv, random + import csv, random # pylint: disable=multiple-imports log.info('runner started') for i in xrange(self.config.number_of_ports): rows = [['power', 'voltage']] + [[random.gauss(1.0, 1.0), random.gauss(1.0, 0.1)] diff --git a/wlauto/instrumentation/daq/__init__.py b/wlauto/instrumentation/daq/__init__.py index 8c3d60e1..3e3517b6 100644 --- a/wlauto/instrumentation/daq/__init__.py +++ b/wlauto/instrumentation/daq/__init__.py @@ -31,6 +31,7 @@ from wlauto.exceptions import ConfigError, InstrumentError, DeviceError from wlauto.utils.misc import ensure_directory_exists as _d from wlauto.utils.types import list_of_ints, list_of_strs, boolean +# pylint: disable=wrong-import-position,wrong-import-order daqpower_path = os.path.join(os.path.dirname(__file__), '..', '..', 'external', 'daq_server', 'src') sys.path.insert(0, daqpower_path) try: @@ -283,7 +284,7 @@ class Daq(Instrument): self._results = None self._metrics = set() if self.labels: - if not (len(self.labels) == len(self.resistor_values)): # pylint: disable=superfluous-parens + if len(self.labels) != len(self.resistor_values): raise ConfigError('Number of DAQ port labels does not match the number of resistor values.') else: self.labels = ['PORT_{}'.format(i) for i, _ in enumerate(self.resistor_values)] @@ -319,7 +320,7 @@ class Daq(Instrument): for name in old_names: if name not in self.labels: raise ConfigError("No channel with label {} specified".format(name)) - self.label_map = self.merge_channels + self.label_map = self.merge_channels # pylint: disable=redefined-variable-type self.merge_channels = True else: # Should never reach here raise AssertionError("Merge files is of invalid type") diff --git a/wlauto/instrumentation/energy_model/__init__.py b/wlauto/instrumentation/energy_model/__init__.py index 06a5abad..bd55cc59 100644 --- a/wlauto/instrumentation/energy_model/__init__.py +++ b/wlauto/instrumentation/energy_model/__init__.py @@ -820,7 +820,7 @@ def _adjust_for_thermal(data, filt_method=lambda x: x, thresh=0.9, window=5000, if __name__ == '__main__': - import sys + import sys # pylint: disable=wrong-import-position,wrong-import-order indir, outdir = sys.argv[1], sys.argv[2] device_name = 'odroidxu3' big_core = 'a15' diff --git a/wlauto/instrumentation/fps/__init__.py b/wlauto/instrumentation/fps/__init__.py index 19299aef..4acd4574 100644 --- a/wlauto/instrumentation/fps/__init__.py +++ b/wlauto/instrumentation/fps/__init__.py @@ -27,6 +27,10 @@ import tempfile from distutils.version import LooseVersion +try: + import pandas as pd +except ImportError: + pd = None from wlauto import Instrument, Parameter, IterationResult from wlauto.instrumentation import instrument_is_installed @@ -34,11 +38,6 @@ from wlauto.exceptions import (InstrumentError, WorkerThreadError, ConfigError, DeviceNotRespondingError, TimeoutError) from wlauto.utils.types import boolean, numeric -try: - import pandas as pd -except ImportError: - pd = None - VSYNC_INTERVAL = 16666667 PAUSE_LATENCY = 20 diff --git a/wlauto/instrumentation/perf/__init__.py b/wlauto/instrumentation/perf/__init__.py index 010ff1fc..2fab8e38 100644 --- a/wlauto/instrumentation/perf/__init__.py +++ b/wlauto/instrumentation/perf/__init__.py @@ -148,7 +148,7 @@ class PerfInstrument(Instrument): self.events = [self.events] if not self.labels: # pylint: disable=E0203 self.labels = ['perf_{}'.format(i) for i in xrange(len(self.optionstrings))] - if not len(self.labels) == len(self.optionstrings): + if len(self.labels) != len(self.optionstrings): raise ConfigError('The number of labels must match the number of optstrings provided for perf.') def _build_commands(self): @@ -173,4 +173,3 @@ class PerfInstrument(Instrument): event_string, self._get_device_outfile(label)) return command - diff --git a/wlauto/instrumentation/pmu_logger/__init__.py b/wlauto/instrumentation/pmu_logger/__init__.py index 9c8fecc4..42b4070e 100644 --- a/wlauto/instrumentation/pmu_logger/__init__.py +++ b/wlauto/instrumentation/pmu_logger/__init__.py @@ -146,7 +146,7 @@ class CciPmuLogger(Instrument): raise ConfigError('To use cci_pmu_logger, trace-cmd instrument must also be enabled.') if not self.event_labels: # pylint: disable=E0203 self.event_labels = ['event_{}'.format(e) for e in self.events] - elif not len(self.events) == len(self.event_labels): + elif len(self.events) != len(self.event_labels): raise ConfigError('cci_pmu_events and cci_pmu_event_labels must be of the same length.') if len(self.events) > NUMBER_OF_CCI_PMU_COUNTERS: raise ConfigError('The number cci_pmu_counters must be at most {}'.format(NUMBER_OF_CCI_PMU_COUNTERS)) diff --git a/wlauto/result_processors/ipynb_exporter/__init__.py b/wlauto/result_processors/ipynb_exporter/__init__.py index 83f56735..7c35866c 100644 --- a/wlauto/result_processors/ipynb_exporter/__init__.py +++ b/wlauto/result_processors/ipynb_exporter/__init__.py @@ -20,15 +20,17 @@ import os import shutil import webbrowser +try: + import jinja2 +except ImportError: + jinja2 = None + from wlauto import File, Parameter, ResultProcessor from wlauto.exceptions import ConfigError, ResultProcessorError import wlauto.utils.ipython as ipython from wlauto.utils.misc import open_file -try: - import jinja2 -except ImportError: - jinja2 = None + DEFAULT_NOTEBOOK_TEMPLATE = 'template.ipynb' diff --git a/wlauto/tests/test_config.py b/wlauto/tests/test_config.py index 40eac92b..f5d8b24c 100644 --- a/wlauto/tests/test_config.py +++ b/wlauto/tests/test_config.py @@ -51,6 +51,7 @@ workloads: instrumentation: [fsp] """ + class MockExtensionLoader(object): def __init__(self): @@ -94,7 +95,7 @@ class NamedMock(object): self.parameters = [] def __getattr__(self, name): - if not name in self.__attrs: + if name not in self.__attrs: self.__attrs[name] = NamedMock(name) return self.__attrs[name] @@ -164,7 +165,7 @@ class ConfigTest(TestCase): def test_list_defaults_params(self): ws = AgendaWorkloadEntry(id='a', iterations=1, - name='defaults_workload', workload_parameters={'param':[3]}) + name='defaults_workload', workload_parameters={'param': [3]}) self.config.set_agenda(MockAgenda(ws)) spec = self.config.workload_specs[0] assert_equal(spec.workload_parameters, {'param': [3]}) diff --git a/wlauto/tests/test_execution.py b/wlauto/tests/test_execution.py index 9482ffaa..e30156a0 100644 --- a/wlauto/tests/test_execution.py +++ b/wlauto/tests/test_execution.py @@ -82,8 +82,10 @@ class BadDeviceMeta(DeviceMeta): basemethods = [getattr(b, vmname) for b in bases if hasattr(b, vmname)] methods[vmname] = [bm for bm in basemethods if bm != clsmethod] methods[vmname].append(clsmethod) + def generate_method_wrapper(vname): name__ = vmname + def wrapper(self, *args, **kwargs): for dm in methods[name__]: dm(self, *args, **kwargs) @@ -101,31 +103,31 @@ class BadDevice(Device): self.exception = exception def connect(self): - if 'connect' == self.when_to_fail: + if self.when_to_fail == 'connect': raise self.exception("Connection failure") def initialize(self, _): - if 'initialize' == self.when_to_fail: + if self.when_to_fail == 'initialize': raise self.exception("Initialisation failure") def get_properties(self, _): - if 'get_properties' == self.when_to_fail: + if self.when_to_fail == 'get_properties': raise self.exception("Failure getting propeties") def start(self): - if 'start' == self.when_to_fail: + if self.when_to_fail == 'start': raise self.exception("Start failure") def set_device_parameters(self, **_): - if 'set_device_parameters' == self.when_to_fail: + if self.when_to_fail == 'set_device_parameters': raise self.exception("Failure setting parameter") def stop(self): - if 'stop' == self.when_to_fail: + if self.when_to_fail == 'stop': raise self.exception("Stop failure") def disconnect(self): - if 'disconnect' == self.when_to_fail: + if self.when_to_fail == 'disconnect': raise self.exception("Disconnection failure") def ping(self): @@ -718,14 +720,14 @@ class RunnerTest(TestCase): expected_signals = [ signal.RUN_START.name, signal.RUN_INIT.name, - signal.WORKLOAD_SPEC_START.name, #Fail Setup + signal.WORKLOAD_SPEC_START.name, # Fail Setup signal.ITERATION_START.name, signal.BEFORE_WORKLOAD_SETUP.name, signal.AFTER_WORKLOAD_SETUP.name, signal.ITERATION_END.name, #Skipped iteration signal.WORKLOAD_SPEC_END.name, - signal.WORKLOAD_SPEC_START.name, #Fail Run + signal.WORKLOAD_SPEC_START.name, # Fail Run signal.ITERATION_START.name, signal.BEFORE_WORKLOAD_SETUP.name, signal.SUCCESSFUL_WORKLOAD_SETUP.name, @@ -753,7 +755,7 @@ class RunnerTest(TestCase): signal.AFTER_WORKLOAD_TEARDOWN.name, signal.ITERATION_END.name, signal.WORKLOAD_SPEC_END.name, - signal.WORKLOAD_SPEC_START.name, # Fail Result Update + signal.WORKLOAD_SPEC_START.name, # Fail Result Update signal.ITERATION_START.name, signal.BEFORE_WORKLOAD_SETUP.name, signal.SUCCESSFUL_WORKLOAD_SETUP.name, @@ -781,7 +783,7 @@ class RunnerTest(TestCase): signal.AFTER_WORKLOAD_TEARDOWN.name, signal.ITERATION_END.name, signal.WORKLOAD_SPEC_END.name, - signal.WORKLOAD_SPEC_START.name, # Fail Teardown + signal.WORKLOAD_SPEC_START.name, # Fail Teardown signal.ITERATION_START.name, signal.BEFORE_WORKLOAD_SETUP.name, signal.SUCCESSFUL_WORKLOAD_SETUP.name, @@ -809,7 +811,7 @@ class RunnerTest(TestCase): signal.AFTER_WORKLOAD_TEARDOWN.name, signal.ITERATION_END.name, signal.WORKLOAD_SPEC_END.name, - signal.WORKLOAD_SPEC_START.name, #OK + signal.WORKLOAD_SPEC_START.name, # OK signal.ITERATION_START.name, signal.BEFORE_WORKLOAD_SETUP.name, signal.SUCCESSFUL_WORKLOAD_SETUP.name, @@ -1065,4 +1067,3 @@ class RunnerTest(TestCase): def _instantiate(cls, *args, **kwargs): # Needed to get around Extension's __init__ checks return cls(*args, **kwargs) - diff --git a/wlauto/utils/android.py b/wlauto/utils/android.py index ec7abd81..b05cf6f8 100644 --- a/wlauto/utils/android.py +++ b/wlauto/utils/android.py @@ -222,11 +222,7 @@ def poll_for_file(device, dfile): command = "adb " + device_string + " shell \" if [ -f " + dfile + " ] ; then true ; else false ; fi\" " logger.debug(command) result = subprocess.call(command, stderr=subprocess.PIPE, shell=True) - if not result: - return True - else: - return False - + return not bool(result) am_start_error = re.compile(r"Error: Activity class {[\w|.|/]*} does not exist") diff --git a/wlauto/utils/ipython.py b/wlauto/utils/ipython.py index bb18adb4..8eb9a9ac 100644 --- a/wlauto/utils/ipython.py +++ b/wlauto/utils/ipython.py @@ -18,6 +18,7 @@ import os import subprocess from distutils.version import StrictVersion +# pylint: disable=wrong-import-position import_error_str = '' try: import IPython @@ -28,7 +29,7 @@ except ImportError as import_error: if import_error.message.startswith("No module named"): # pylint: disable=E1101 import_error_str = 'ipynb_exporter requires ipython package to be installed' else: - import_error_str = import_error.message + import_error_str = import_error.message # pylint: disable=redefined-variable-type # The current code generates notebooks version 3 NBFORMAT_VERSION = 3 diff --git a/wlauto/utils/misc.py b/wlauto/utils/misc.py index 3bc306ec..1444b792 100644 --- a/wlauto/utils/misc.py +++ b/wlauto/utils/misc.py @@ -250,7 +250,7 @@ def get_traceback(exc=None): def merge_dicts(*args, **kwargs): - if not len(args) >= 2: + if len(args) < 2: raise ValueError('Must specify at least two dicts to merge.') func = partial(_merge_two_dicts, **kwargs) return reduce(func, args) @@ -314,7 +314,7 @@ def _merge_two_dicts(base, other, list_duplicates='all', match_types=False, # p def merge_lists(*args, **kwargs): - if not len(args) >= 2: + if len(args) < 2: raise ValueError('Must specify at least two lists to merge.') func = partial(_merge_two_lists, **kwargs) return reduce(func, args) @@ -696,7 +696,7 @@ def load_struct_from_python(filepath=None, text=None): for k, v in mod.__dict__.iteritems() if not k.startswith('_')) except SyntaxError as e: - raise LoadSyntaxError(e.message, e.filepath, e.lineno) + raise LoadSyntaxError(e.message, filepath, e.lineno) def load_struct_from_yaml(filepath=None, text=None): @@ -713,7 +713,7 @@ def load_struct_from_yaml(filepath=None, text=None): except yaml.YAMLError as e: lineno = None if hasattr(e, 'problem_mark'): - lineno = e.problem_mark.line + lineno = e.problem_mark.line # pylint: disable=no-member raise LoadSyntaxError(e.message, filepath=filepath, lineno=lineno) diff --git a/wlauto/utils/netio.py b/wlauto/utils/netio.py index e6c2a7e0..a130d8c4 100644 --- a/wlauto/utils/netio.py +++ b/wlauto/utils/netio.py @@ -51,7 +51,7 @@ class KshellConnection(object): def login(self, user, password): code, out = self.send_command('login {} {}\r\n'.format(user, password)) - if not code == 250: + if code != 250: raise NetioError('Login failed. Got: {} {}'.format(code, out)) def enable_port(self, port): @@ -64,7 +64,7 @@ class KshellConnection(object): def set_port(self, port, value): code, out = self.send_command('port {} {}'.format(port, value)) - if not code == 250: + if code != 250: raise NetioError('Could not set {} on port {}. Got: {} {}'.format(value, port, code, out)) def send_command(self, command): @@ -95,4 +95,3 @@ class KshellConnection(object): def close(self): self.conn.close() - diff --git a/wlauto/utils/serial_port.py b/wlauto/utils/serial_port.py index 25dc8e18..3dc0f0cd 100644 --- a/wlauto/utils/serial_port.py +++ b/wlauto/utils/serial_port.py @@ -19,6 +19,8 @@ from contextlib import contextmanager from distutils.version import StrictVersion as V import serial + +# pylint: disable=ungrouped-imports import pexpect if V(pexpect.__version__) < V('4.0.0'): import fdpexpect # pylint: disable=import-error @@ -118,5 +120,3 @@ def open_serial_connection(timeout, get_conn=False, init_dtr=None, *args, **kwar target.close() # Closes the file descriptor used by the conn. del conn - - diff --git a/wlauto/utils/ssh.py b/wlauto/utils/ssh.py index 3b1ac9c4..824bac17 100644 --- a/wlauto/utils/ssh.py +++ b/wlauto/utils/ssh.py @@ -43,7 +43,7 @@ def ssh_get_shell(host, username, password=None, keyfile=None, port=None, timeou raise ConfigError('keyfile may not be used with a telnet connection.') conn = TelnetConnection() else: # ssh - conn = pxssh.pxssh() + conn = pxssh.pxssh() # pylint: disable=redefined-variable-type try: if keyfile: conn.login(host, username, ssh_key=keyfile, port=port, login_timeout=timeout) @@ -274,4 +274,3 @@ def process_backspaces(text): else: chars.append(c) return ''.join(chars) - diff --git a/wlauto/workloads/antutu/__init__.py b/wlauto/workloads/antutu/__init__.py index 65cdeed3..580e9daa 100644 --- a/wlauto/workloads/antutu/__init__.py +++ b/wlauto/workloads/antutu/__init__.py @@ -79,7 +79,7 @@ class Antutu(AndroidUiAutoBenchmark): if self.version == '4.0.3': metrics = extract_version4_metrics(fh) else: - metrics = extract_older_version_metrics(fh) + metrics = extract_older_version_metrics(fh) # pylint: disable=redefined-variable-type for key, value in metrics.iteritems(): key = key.replace(' ', '_') context.result.add_metric(key, value) @@ -118,7 +118,7 @@ def extract_older_version_metrics(fh): for line in fh: if 'i/antutu' in line.lower(): parts = line.split(':') - if not len(parts) == 3: + if len(parts) != 3: continue metric = parts[1].strip() value = int(parts[2].strip()) @@ -132,4 +132,3 @@ def extract_older_version_metrics(fh): metrics[metric] = value return metrics - diff --git a/wlauto/workloads/ebizzy/__init__.py b/wlauto/workloads/ebizzy/__init__.py index 100bf0aa..2aabfcfa 100644 --- a/wlauto/workloads/ebizzy/__init__.py +++ b/wlauto/workloads/ebizzy/__init__.py @@ -14,11 +14,11 @@ # pylint: disable=W0201, C0103 -from wlauto import Workload, Parameter, Executable - import os import re +from wlauto import Workload, Parameter, Executable + results_txt = 'ebizzy_results.txt' record_regex = re.compile(r'(?P\d+) records/s') result_regex = re.compile(r'(?P\D+)(?P\d+.*\b)(?P\S+)') diff --git a/wlauto/workloads/hackbench/__init__.py b/wlauto/workloads/hackbench/__init__.py index 64c35186..dbb294e7 100644 --- a/wlauto/workloads/hackbench/__init__.py +++ b/wlauto/workloads/hackbench/__init__.py @@ -14,11 +14,12 @@ # pylint: disable=W0201, C0103 -from wlauto import Workload, Parameter, Executable - import os import re +from wlauto import Workload, Parameter, Executable + + hackbench_results_txt = 'hackbench_results.txt' regex_map = {"total_groups": (re.compile(r'(\d+) groups'), "groups"), diff --git a/wlauto/workloads/idle/__init__.py b/wlauto/workloads/idle/__init__.py index db4737e4..8c85a289 100644 --- a/wlauto/workloads/idle/__init__.py +++ b/wlauto/workloads/idle/__init__.py @@ -44,7 +44,7 @@ class IdleWorkload(Workload): def setup(self, context): if self.stop_android: - if not self.device.platform == 'android': + if self.device.platform != 'android': raise ConfigError('stop_android can only be set for Android devices') if not self.device.is_rooted: raise WorkloadError('Idle workload requires the device to be rooted in order to stop Android.') @@ -66,4 +66,3 @@ class IdleWorkload(Workload): time.sleep(0.2) while self.device.execute('getprop init.svc.bootanim').strip() == 'running': time.sleep(1) - diff --git a/wlauto/workloads/iozone/__init__.py b/wlauto/workloads/iozone/__init__.py index 57bbfe46..95c9b191 100644 --- a/wlauto/workloads/iozone/__init__.py +++ b/wlauto/workloads/iozone/__init__.py @@ -12,16 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=attribute-defined-outside-init - -from wlauto import Workload, Parameter, Executable -from wlauto.exceptions import ConfigError -from wlauto.utils.types import list_of_ints from collections import OrderedDict from itertools import izip_longest import os import re import csv + +from wlauto import Workload, Parameter, Executable +from wlauto.exceptions import ConfigError +from wlauto.utils.types import list_of_ints + + iozone_results_txt = 'iozone_results.txt' diff --git a/wlauto/workloads/spec2000/__init__.py b/wlauto/workloads/spec2000/__init__.py index 4d44d525..1ff043d3 100644 --- a/wlauto/workloads/spec2000/__init__.py +++ b/wlauto/workloads/spec2000/__init__.py @@ -119,10 +119,7 @@ class Spec2000(Workload): # (also more than just summary/non-summary classification?) class _SPECSummaryMetrics(object): def __contains__(self, item): - if item.endswith('_real'): - return True - else: - return False + return item.endswith('_real') asset_file = 'spec2000-assets.tar.gz' @@ -351,4 +348,3 @@ class CommandSpec(object): self.datadir = None self.command = None self.threads = None - diff --git a/wlauto/workloads/stream/__init__.py b/wlauto/workloads/stream/__init__.py index 6e4d9dcf..30eda2db 100644 --- a/wlauto/workloads/stream/__init__.py +++ b/wlauto/workloads/stream/__init__.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=attribute-defined-outside-init +import os +import re from wlauto import Workload, Parameter, Executable -import os -import re stream_results_txt = 'stream_results.txt' system_array_regex = re.compile(r'^This system uses (\d)') diff --git a/wlauto/workloads/telemetry/__init__.py b/wlauto/workloads/telemetry/__init__.py index a56e9343..5333c098 100644 --- a/wlauto/workloads/telemetry/__init__.py +++ b/wlauto/workloads/telemetry/__init__.py @@ -300,8 +300,7 @@ def parse_telemetry_results(filepath): if __name__ == '__main__': - import sys - from pprint import pprint + import sys # pylint: disable=wrong-import-order,wrong-import-position + from pprint import pprint # pylint: disable=wrong-import-order,wrong-import-position path = sys.argv[1] pprint(parse_telemetry_results(path)) -