summaryrefslogtreecommitdiff
path: root/bin
diff options
authorJonathan Cave <jonathan.cave@canonical.com>2022-08-15 17:54:12 +0100
committerJonathan Cave <jonathan.cave@canonical.com>2022-08-15 17:54:12 +0100
commit48bbaa9d8b86618c9d4e5b8f049e601f22f56ab8 (patch)
treed7576974013b574e871d7b095716650159c83c78 /bin
parentad16f69fa2ba0705a5c7100ab8d7f2def41566eb (diff)
Fix: new flake8 fails for python3.10
Now flake8 testing is also being running on jammy with python 3.10 there are some new fails that need ignoring of fixing. This is simple modification to achieve a pass.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/alsa_pcm_info.py2
-rwxr-xr-xbin/i2c_driver_test.py6
-rwxr-xr-xbin/pm_test.py20
-rwxr-xr-xbin/removable_storage_test.py10
4 files changed, 21 insertions, 17 deletions
diff --git a/bin/alsa_pcm_info.py b/bin/alsa_pcm_info.py
index abb870f..fe3a744 100755
--- a/bin/alsa_pcm_info.py
+++ b/bin/alsa_pcm_info.py
@@ -17,7 +17,7 @@ PCM_FILE = '/proc/asound/pcm'
if os.path.exists(PCM_FILE):
with open(PCM_FILE, 'r') as f:
for line in f:
- t = [l.strip() for l in line.split(':')]
+ t = [device_line.strip() for device_line in line.split(':')]
# 0 = Card and device id
ids = t[0].split('-')
print("Card: {}".format(ids[0]))
diff --git a/bin/i2c_driver_test.py b/bin/i2c_driver_test.py
index c6aae78..a5c11f2 100755
--- a/bin/i2c_driver_test.py
+++ b/bin/i2c_driver_test.py
@@ -68,9 +68,9 @@ class Device():
result = subprocess.check_output(['i2cdetect', '-y', '-r', str(i)],
universal_newlines=True)
print(result)
- result_line = result.splitlines()[1:]
- for l in result_line:
- address_value = l.strip('\n').split(':')[1].split()
+ result_lines = result.splitlines()[1:]
+ for r in result_lines:
+ address_value = r.strip('\n').split(':')[1].split()
for v in address_value:
if v != '--':
exit_code = 0
diff --git a/bin/pm_test.py b/bin/pm_test.py
index 92a5863..e6edb88 100755
--- a/bin/pm_test.py
+++ b/bin/pm_test.py
@@ -257,10 +257,10 @@ class PowerManagementOperation():
problems = ''
fwts_log_path = os.path.join(self.args.log_dir, 'fwts.log')
try:
- with open(fwts_log_path, 'rt') as f:
+ with open(fwts_log_path, 'rt') as fwts_log:
magic_line_s3 = 'Completed S3 cycle(s) \n'
magic_line_s2idle = 'Completed s2idle cycle(s) \n'
- lines = f.readlines()
+ lines = fwts_log.readlines()
count_s3 = lines.count(magic_line_s3)
count_s2idle = lines.count(magic_line_s2idle)
count = count_s3 + count_s2idle
@@ -277,8 +277,8 @@ class PowerManagementOperation():
'comments': problems,
}
result_filename = os.path.join(self.args.log_dir, '__result')
- with open(result_filename, 'wt') as f:
- json.dump(result, f)
+ with open(result_filename, 'wt') as result_f:
+ json.dump(result, result_f)
if self.args.silent:
logging.info(message)
@@ -298,9 +298,9 @@ class PowerManagementOperation():
# x-terminal-emulator command does not work on Wayland
# Run the checkbox_respawn_cmd via subprocess.run instead
except subprocess.CalledProcessError:
- with open(self.args.checkbox_respawn_cmd, 'rt') as f:
- for l in f:
- subprocess.run(l, shell=True)
+ with open(self.args.checkbox_respawn_cmd, 'rt') as respawn_f:
+ for respawn_cmd in respawn_f:
+ subprocess.run(respawn_cmd, shell=True)
def teardown(self):
"""
@@ -430,6 +430,7 @@ class Command():
Simple subprocess.Popen wrapper to run shell commands
and log their output
"""
+
def __init__(self, command_str, verbose=True):
self.command_str = command_str
self.verbose = verbose
@@ -479,6 +480,7 @@ class CountdownDialog(Gtk.Dialog):
Dialog that shows the amount of progress in the reboot test
and lets the user cancel it if needed
"""
+
def __init__(self, pm_operation, pm_delay, hardware_delay,
iterations, iterations_count):
self.pm_operation = pm_operation
@@ -643,6 +645,7 @@ class MessageDialog():
"""
Simple wrapper aroung Gtk.MessageDialog
"""
+
def __init__(self, title, message, type=Gtk.MessageType.INFO):
self.title = title
self.message = message
@@ -663,6 +666,7 @@ class AutoLoginConfigurator():
Enable/disable autologin configuration
to make sure that reboot test will work properly
"""
+
def __init__(self, user=None):
self.user = user
self.config_filename = '/etc/lightdm/lightdm.conf'
@@ -751,7 +755,6 @@ class SudoersConfigurator():
"{user} ALL=NOPASSWD: /usr/bin/python3' "
"{filename}".format(mark=self.MARK,
user=self.user,
- script=os.path.realpath(__file__),
filename=self.SUDOERS))
Command(command, verbose=False).run()
@@ -891,6 +894,7 @@ class MyArgumentParser():
"""
Command-line argument parser
"""
+
def __init__(self):
"""
Create parser object
diff --git a/bin/removable_storage_test.py b/bin/removable_storage_test.py
index 4dcd5b2..9fd4fd5 100755
--- a/bin/removable_storage_test.py
+++ b/bin/removable_storage_test.py
@@ -19,7 +19,7 @@ gi.require_version('GUdev', '1.0')
from gi.repository import GUdev # noqa: E402
from checkbox_support.dbus import connect_to_system_bus # noqa: E402
-from checkbox_support.dbus.udisks2 import (
+from checkbox_support.dbus.udisks2 import ( # noqa: E402
UDISKS2_BLOCK_INTERFACE,
UDISKS2_DRIVE_INTERFACE,
UDISKS2_FILESYSTEM_INTERFACE,
@@ -28,11 +28,11 @@ from checkbox_support.dbus.udisks2 import (
UDisks2Observer,
is_udisks2_supported,
lookup_udev_device,
- map_udisks1_connection_bus) # noqa: E402
+ map_udisks1_connection_bus)
from checkbox_support.heuristics.udisks2 import is_memory_card # noqa: E402
-from checkbox_support.helpers.human_readable_bytes import (
- HumanReadableBytes) # noqa: E402
-from checkbox_support.parsers.udevadm import (
+from checkbox_support.helpers.human_readable_bytes import ( # noqa: E402
+ HumanReadableBytes)
+from checkbox_support.parsers.udevadm import ( # noqa: E402
CARD_READER_RE,
GENERIC_RE,
FLASH_RE,