summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-07-08 14:22:19 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-13 17:06:03 +0000
commit331ea002e16c1209e1eddf57c01400b7ff4ac02e (patch)
tree0dc3933e35417500dc9b92cfc722058df17f859e /extra
parentb330c438eed93c2dddecfe767a1bacfca4883227 (diff)
downloadchrome-ec-331ea002e16c1209e1eddf57c01400b7ff4ac02e.tar.gz
ec: Fix some bad formatting and warnings
The black formatting revealed some odd formatting. Fixed all errors from cros lint. find . \( -path ./private -prune \) -o -name '*.py' -print | \ xargs cros lint -v |& grep ": E" BRANCH=None BUG=b:238434058 TEST=None Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ia1d2e9cfb0cd2b7000d15b3b918d24881987673e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3749249 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'extra')
-rwxr-xr-xextra/cr50_rma_open/cr50_rma_open.py20
-rwxr-xr-xextra/stack_analyzer/stack_analyzer.py8
-rwxr-xr-xextra/stack_analyzer/stack_analyzer_unittest.py6
-rw-r--r--extra/tigertool/ecusb/__init__.py4
-rw-r--r--extra/tigertool/ecusb/pty_driver.py8
-rw-r--r--extra/tigertool/ecusb/stm32uart.py6
-rw-r--r--extra/tigertool/ecusb/stm32usb.py6
-rw-r--r--extra/tigertool/ecusb/tiny_servo_common.py6
-rw-r--r--extra/tigertool/ecusb/tiny_servod.py4
-rwxr-xr-xextra/tigertool/tigertest.py4
-rwxr-xr-xextra/tigertool/tigertool.py4
-rw-r--r--extra/usb_power/convert_power_log_board.py6
-rwxr-xr-xextra/usb_power/convert_servo_ina.py4
-rwxr-xr-xextra/usb_power/powerlog.py15
-rw-r--r--extra/usb_power/powerlog_unittest.py6
-rw-r--r--extra/usb_power/stats_manager.py6
-rw-r--r--extra/usb_power/stats_manager_unittest.py6
-rwxr-xr-xextra/usb_serial/console.py13
-rwxr-xr-xextra/usb_updater/fw_update.py12
-rwxr-xr-xextra/usb_updater/servo_updater.py6
20 files changed, 31 insertions, 119 deletions
diff --git a/extra/cr50_rma_open/cr50_rma_open.py b/extra/cr50_rma_open/cr50_rma_open.py
index b77b8f3dbb..47cb7cd6e3 100755
--- a/extra/cr50_rma_open/cr50_rma_open.py
+++ b/extra/cr50_rma_open/cr50_rma_open.py
@@ -50,16 +50,14 @@ import subprocess
import sys
import time
-import serial
+import serial # pylint:disable=import-error
SCRIPT_VERSION = 5
CCD_IS_UNRESTRICTED = 1 << 0
WP_IS_DISABLED = 1 << 1
TESTLAB_IS_ENABLED = 1 << 2
RMA_OPENED = CCD_IS_UNRESTRICTED | WP_IS_DISABLED
-URL = (
- "https://www.google.com/chromeos/partner/console/cr50reset?" "challenge=%s&hwid=%s"
-)
+URL = "https://www.google.com/chromeos/partner/console/cr50reset?challenge=%s&hwid=%s"
RMA_SUPPORT_PROD = "0.3.3"
RMA_SUPPORT_PREPVT = "0.4.5"
DEV_MODE_OPEN_PROD = "0.3.9"
@@ -398,7 +396,7 @@ class RMAOpen(object):
self.send_cmd_get_output("ccd open")
logging.info("Enabling testlab mode reqires pressing the power button.")
logging.info(
- "Once the process starts keep tapping the power button " "for 10 seconds."
+ "Once the process starts keep tapping the power button for 10 seconds."
)
input("Press Enter when you're ready to start...")
end_time = time.time() + 15
@@ -473,11 +471,11 @@ class RMAOpen(object):
rma_support,
)
if not self.is_prepvt and self._running_version_is_older(TESTLAB_PROD):
- raise ValueError("Update cr50. No testlab support in old prod " "images.")
+ raise ValueError("Update cr50. No testlab support in old prod images.")
if self._running_version_is_older(rma_support):
raise ValueError(
- "%s does not have RMA support. Update to at "
- "least %s" % (version, rma_support)
+ "%s does not have RMA support. Update to at least %s"
+ % (version, rma_support)
)
def _running_version_is_older(self, target_ver):
@@ -538,7 +536,7 @@ class RMAOpen(object):
return
logging.warning(DEBUG_CONNECTION)
raise ValueError(
- "Found USB device, but could not communicate with " "cr50 console"
+ "Found USB device, but could not communicate with cr50 console"
)
def print_platform_info(self):
@@ -578,7 +576,7 @@ class RMAOpen(object):
logging.info("CCD is still restricted.")
logging.info("Run cr50_rma_open.py -g -i $HWID to generate a url")
logging.info(
- "Run cr50_rma_open.py -a $AUTHCODE to open cr50 with " "an authcode"
+ "Run cr50_rma_open.py -a $AUTHCODE to open cr50 with an authcode"
)
elif not self.check(WP_IS_DISABLED):
logging.info("WP is still enabled.")
@@ -692,7 +690,7 @@ def main(argv):
"open. Run through the rma open process first"
)
if tried_authcode:
- logging.warning("RMA Open did not disable write protect. File a " "bug")
+ logging.warning("RMA Open did not disable write protect. File a bug")
logging.warning("Trying to disable it manually")
cr50_rma_open.wp_disable()
diff --git a/extra/stack_analyzer/stack_analyzer.py b/extra/stack_analyzer/stack_analyzer.py
index 17b2651972..9feb2423c9 100755
--- a/extra/stack_analyzer/stack_analyzer.py
+++ b/extra/stack_analyzer/stack_analyzer.py
@@ -2,10 +2,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Statically analyze stack usage of EC firmware.
@@ -26,7 +22,7 @@ import os
import re
import subprocess
-import yaml
+import yaml # pylint:disable=import-error
SECTION_RO = "RO"
SECTION_RW = "RW"
@@ -1165,7 +1161,7 @@ class StackAnalyzer(object):
if not name:
raise StackAnalyzerError(
- "Cannot find function for address %s.", hex(val)
+ "Cannot find function for address %s." % hex(val)
)
output.append((name, None, None))
diff --git a/extra/stack_analyzer/stack_analyzer_unittest.py b/extra/stack_analyzer/stack_analyzer_unittest.py
index ad2837a8a4..228b7e010e 100755
--- a/extra/stack_analyzer/stack_analyzer_unittest.py
+++ b/extra/stack_analyzer/stack_analyzer_unittest.py
@@ -2,10 +2,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Tests for Stack Analyzer classes and functions."""
@@ -15,7 +11,7 @@ import os
import subprocess
import unittest
-import mock
+import mock # pylint:disable=import-error
import stack_analyzer as sa
diff --git a/extra/tigertool/ecusb/__init__.py b/extra/tigertool/ecusb/__init__.py
index 7a48fdb360..7228f2b911 100644
--- a/extra/tigertool/ecusb/__init__.py
+++ b/extra/tigertool/ecusb/__init__.py
@@ -1,9 +1,5 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
__all__ = ["tiny_servo_common", "stm32usb", "stm32uart", "pty_driver"]
diff --git a/extra/tigertool/ecusb/pty_driver.py b/extra/tigertool/ecusb/pty_driver.py
index 037ff8d529..c87378b94d 100644
--- a/extra/tigertool/ecusb/pty_driver.py
+++ b/extra/tigertool/ecusb/pty_driver.py
@@ -1,10 +1,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""ptyDriver class
@@ -19,8 +15,8 @@ import fcntl
import os
import time
-import pexpect
-from pexpect import fdpexpect
+import pexpect # pylint:disable=import-error
+from pexpect import fdpexpect # pylint:disable=import-error
# Expecting a result in 3 seconds is plenty even for slow platforms.
DEFAULT_UART_TIMEOUT = 3
diff --git a/extra/tigertool/ecusb/stm32uart.py b/extra/tigertool/ecusb/stm32uart.py
index 5794bd091b..a6fa73970d 100644
--- a/extra/tigertool/ecusb/stm32uart.py
+++ b/extra/tigertool/ecusb/stm32uart.py
@@ -1,10 +1,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Allow creation of uart/console interface via stm32 usb endpoint."""
@@ -18,7 +14,7 @@ import threading
import time
import tty
-import usb
+import usb # pylint:disable=import-error
from . import stm32usb
diff --git a/extra/tigertool/ecusb/stm32usb.py b/extra/tigertool/ecusb/stm32usb.py
index 4b2b23fbac..e8a0bc4f9b 100644
--- a/extra/tigertool/ecusb/stm32usb.py
+++ b/extra/tigertool/ecusb/stm32usb.py
@@ -1,14 +1,10 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Allows creation of an interface via stm32 usb."""
-import usb
+import usb # pylint:disable=import-error
class SusbError(Exception):
diff --git a/extra/tigertool/ecusb/tiny_servo_common.py b/extra/tigertool/ecusb/tiny_servo_common.py
index 599bae80dc..889abcc0a0 100644
--- a/extra/tigertool/ecusb/tiny_servo_common.py
+++ b/extra/tigertool/ecusb/tiny_servo_common.py
@@ -1,10 +1,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Utilities for using lightweight console functions."""
@@ -15,7 +11,7 @@ import sys
import time
import six
-import usb
+import usb # pylint:disable=import-error
from . import pty_driver, stm32uart
diff --git a/extra/tigertool/ecusb/tiny_servod.py b/extra/tigertool/ecusb/tiny_servod.py
index ca5ca63f31..d5d092c996 100644
--- a/extra/tigertool/ecusb/tiny_servod.py
+++ b/extra/tigertool/ecusb/tiny_servod.py
@@ -1,10 +1,6 @@
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Helper class to facilitate communication to servo ec console."""
diff --git a/extra/tigertool/tigertest.py b/extra/tigertool/tigertest.py
index 8f8b2c7f03..924ec8c97c 100755
--- a/extra/tigertool/tigertest.py
+++ b/extra/tigertool/tigertest.py
@@ -2,10 +2,6 @@
# Copyright 2022 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Smoke test of tigertool binary."""
diff --git a/extra/tigertool/tigertool.py b/extra/tigertool/tigertool.py
index 37b7b01495..241e7fe155 100755
--- a/extra/tigertool/tigertool.py
+++ b/extra/tigertool/tigertool.py
@@ -2,10 +2,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Script to control tigertail USB-C Mux board."""
diff --git a/extra/usb_power/convert_power_log_board.py b/extra/usb_power/convert_power_log_board.py
index c1b25f57db..159b4621d7 100644
--- a/extra/usb_power/convert_power_log_board.py
+++ b/extra/usb_power/convert_power_log_board.py
@@ -2,10 +2,6 @@
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""
Program to convert sweetberry config to servod config template.
@@ -19,7 +15,7 @@ import json
import os
import sys
-from powerlog import Spower
+from powerlog import Spower # pylint:disable=import-error
def fetch_records(board_file):
diff --git a/extra/usb_power/convert_servo_ina.py b/extra/usb_power/convert_servo_ina.py
index 6ccd474e6c..c18b7368dc 100755
--- a/extra/usb_power/convert_servo_ina.py
+++ b/extra/usb_power/convert_servo_ina.py
@@ -2,10 +2,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Program to convert power logging config from a servo_ina device
to a sweetberry config.
diff --git a/extra/usb_power/powerlog.py b/extra/usb_power/powerlog.py
index d893e5c6b9..44dd6ec12f 100755
--- a/extra/usb_power/powerlog.py
+++ b/extra/usb_power/powerlog.py
@@ -2,10 +2,6 @@
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Program to fetch power logging data from a sweetberry device
or other usb device that exports a USB power logging interface.
@@ -27,8 +23,8 @@ import time
import traceback
from distutils import sysconfig
-import usb
-from stats_manager import StatsManager
+import usb # pylint:disable=import-error
+from stats_manager import StatsManager # pylint:disable=import-error
# Directory where hdctools installs configuration files into.
LIB_DIR = os.path.join(sysconfig.get_python_lib(standard_lib=False), "servo", "data")
@@ -182,11 +178,7 @@ class Spower(object):
if dev is None:
raise Exception("Power", "USB device(%s) not found" % serialname)
else:
- try:
- dev = dev_list[0]
- except TypeError:
- # Incompatible pyUsb version.
- dev = dev_list.next()
+ dev = dev_list[0]
self._logger.debug("Found USB device: %04x:%04x", vendor, product)
self._dev = dev
@@ -728,6 +720,7 @@ class powerlog(object):
if integration_us != integration_us_new:
raise Exception(
"FAIL",
+ # pylint:disable=bad-string-format-type
"Integration on A: %dus != integration on B %dus"
% (integration_us, integration_us_new),
)
diff --git a/extra/usb_power/powerlog_unittest.py b/extra/usb_power/powerlog_unittest.py
index 693826c16d..220ff350d2 100644
--- a/extra/usb_power/powerlog_unittest.py
+++ b/extra/usb_power/powerlog_unittest.py
@@ -1,10 +1,6 @@
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Unit tests for powerlog."""
@@ -13,7 +9,7 @@ import shutil
import tempfile
import unittest
-import powerlog
+from usb_power import powerlog
class TestPowerlog(unittest.TestCase):
diff --git a/extra/usb_power/stats_manager.py b/extra/usb_power/stats_manager.py
index 633312311d..0f92916251 100644
--- a/extra/usb_power/stats_manager.py
+++ b/extra/usb_power/stats_manager.py
@@ -1,10 +1,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Calculates statistics for lists of data and pretty print them."""
@@ -18,7 +14,7 @@ import logging
import math
import os
-import numpy
+import numpy # pylint:disable=import-error
STATS_PREFIX = "@@"
NAN_TAG = "*"
diff --git a/extra/usb_power/stats_manager_unittest.py b/extra/usb_power/stats_manager_unittest.py
index 37a472af98..2a7317546c 100644
--- a/extra/usb_power/stats_manager_unittest.py
+++ b/extra/usb_power/stats_manager_unittest.py
@@ -1,10 +1,6 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Unit tests for StatsManager."""
@@ -17,7 +13,7 @@ import shutil
import tempfile
import unittest
-import stats_manager
+import stats_manager # pylint:disable=import-error
class TestStatsManager(unittest.TestCase):
diff --git a/extra/usb_serial/console.py b/extra/usb_serial/console.py
index c08cb72092..839330d86a 100755
--- a/extra/usb_serial/console.py
+++ b/extra/usb_serial/console.py
@@ -2,10 +2,6 @@
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""Allow creation of uart/console interface via usb google serial endpoint."""
@@ -23,7 +19,7 @@ import time
import tty
try:
- import usb
+ import usb # pylint:disable=import-error
except ModuleNotFoundError:
print("import usb failed")
print("try running these commands:")
@@ -113,12 +109,7 @@ class Susb:
try:
dev = dev_list[0]
except:
- try:
- dev = dev_list.next()
- except:
- raise SusbError(
- "USB device %04x:%04x not found" % (vendor, product)
- )
+ raise SusbError("USB device %04x:%04x not found" % (vendor, product))
# If we can't set configuration, it's already been set.
try:
diff --git a/extra/usb_updater/fw_update.py b/extra/usb_updater/fw_update.py
index f05797bfb6..8658d92c48 100755
--- a/extra/usb_updater/fw_update.py
+++ b/extra/usb_updater/fw_update.py
@@ -2,10 +2,6 @@
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# Upload firmware over USB
# Note: This is a py2/3 compatible file.
@@ -21,7 +17,8 @@ import sys
import time
from pprint import pprint
-import usb
+import usb # pylint:disable=import-error
+from ecusb.stm32usb import SusbError
debug = False
@@ -91,10 +88,7 @@ class Supdate(object):
if dev is None:
raise SusbError("USB device(%s) not found" % serialname)
else:
- try:
- dev = dev_list[0]
- except:
- dev = dev_list.next()
+ dev = dev_list[0]
debuglog("Found stm32: %04x:%04x" % (vendor, product))
self._dev = dev
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py
index 5402af70aa..7fa4608289 100755
--- a/extra/usb_updater/servo_updater.py
+++ b/extra/usb_updater/servo_updater.py
@@ -2,10 +2,6 @@
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# Note: This is a py2/3 compatible file.
@@ -410,7 +406,7 @@ def main():
# If the user only cares about the information then just print it here,
# and exit.
if args.print_only:
- output = ("board: %s\n" "channel: %s\n" "firmware: %s") % (
+ output = ("board: %s\nchannel: %s\nfirmware: %s") % (
args.board,
args.channel,
newvers,