fix linter warnings

(note: the linter test for min/max is buggy so disabled)
This commit is contained in:
Kevin Hester
2024-07-03 09:53:23 -07:00
parent 2f5a736e1f
commit ae2ef78560
7 changed files with 26 additions and 22 deletions

View File

@@ -23,7 +23,7 @@ ignore-patterns=mqtt_pb2.py,channel_pb2.py,telemetry_pb2.py,admin_pb2.py,config_
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
#
disable=invalid-name,fixme,logging-fstring-interpolation,too-many-statements,too-many-branches,too-many-locals,no-member,f-string-without-interpolation,protected-access,pointless-string-statement,too-few-public-methods,broad-except,no-else-return,no-else-raise,bare-except,too-many-public-methods
disable=invalid-name,fixme,logging-fstring-interpolation,too-many-statements,too-many-branches,too-many-locals,no-member,f-string-without-interpolation,protected-access,pointless-string-statement,too-few-public-methods,broad-except,no-else-return,no-else-raise,bare-except,too-many-public-methods,nested-min-max
[BASIC]

View File

@@ -854,7 +854,7 @@ def onConnected(interface):
if args.slog_out or args.power_stress:
# Setup loggers
global meter
global meter # pylint: disable=global-variable-not-assigned
LogSet(interface, args.slog_out if args.slog_out != 'default' else None, meter)
if args.power_stress:
@@ -1001,9 +1001,8 @@ def export_config(interface):
def create_power_meter():
"""Setup the power meter."""
global meter
global meter # pylint: disable=global-statement
args = mt_config.args
meter = None # assume no power meter
if args.power_riden:
meter = RidenPowerSupply(args.power_riden)
elif args.power_ppk2_supply or args.power_ppk2_meter:

View File

@@ -4,4 +4,4 @@ from .power_supply import PowerError, PowerMeter, PowerSupply
from .ppk2 import PPK2PowerSupply
from .riden import RidenPowerSupply
from .sim import SimPowerSupply
from .stress import PowerStress
from .stress import PowerStress

View File

@@ -9,7 +9,6 @@ from ppk2_api import ppk2_api # type: ignore[import-untyped]
from .power_supply import PowerError, PowerSupply
class PPK2PowerSupply(PowerSupply):
"""Interface for talking with the NRF PPK2 high-resolution micro-power supply.
Power Profiler Kit II is what you should google to find it for purchase.
@@ -130,7 +129,9 @@ class PPK2PowerSupply(PowerSupply):
# must be after setting source voltage and before setting mode
self.r.start_measuring() # send command to ppk2
if not s: # min power outpuf of PPK2. If less than this assume we want just meter mode.
if (
not s
): # min power outpuf of PPK2. If less than this assume we want just meter mode.
self.r.use_ampere_meter()
else:
self.r.use_source_meter() # set source meter mode

View File

@@ -3,10 +3,7 @@
import logging
import time
from pubsub import pub # type: ignore[import-untyped]
from meshtastic.protobuf import portnums_pb2
from meshtastic.protobuf.powermon_pb2 import PowerStressMessage
from ..protobuf import ( portnums_pb2, powermon_pb2 )
def onPowerStressResponse(packet, interface):
@@ -20,7 +17,7 @@ class PowerStressClient:
The client stub for talking to the firmware PowerStress module.
"""
def __init__(self, iface, node_id = None):
def __init__(self, iface, node_id=None):
"""
Create a new PowerStressClient instance.
@@ -31,14 +28,18 @@ class PowerStressClient:
if not node_id:
node_id = iface.myInfo.my_node_num
self.node_id = node_id
self.node_id = node_id
# No need to subscribe - because we
# pub.subscribe(onGPIOreceive, "meshtastic.receive.powerstress")
def sendPowerStress(
self, cmd: PowerStressMessage.Opcode.ValueType, num_seconds: float = 0.0, onResponse=None
self,
cmd: powermon_pb2.PowerStressMessage.Opcode.ValueType,
num_seconds: float = 0.0,
onResponse=None,
):
r = PowerStressMessage()
"""Client goo for talking with the device side agent."""
r = powermon_pb2.PowerStressMessage()
r.cmd = cmd
r.num_seconds = num_seconds
@@ -49,16 +50,16 @@ class PowerStressClient:
wantAck=True,
wantResponse=True,
onResponse=onResponse,
onResponseAckPermitted=True
onResponseAckPermitted=True,
)
class PowerStress:
"""Walk the UUT through a set of power states so we can capture repeatable power consumption measurements."""
def __init__(self, iface):
self.client = PowerStressClient(iface)
def run(self):
"""Run the power stress test."""
# Send the power stress command
@@ -68,11 +69,13 @@ class PowerStress:
nonlocal gotAck
gotAck = True
logging.info("Starting power stress test, attempting to contact UUT...")
self.client.sendPowerStress(PowerStressMessage.PRINT_INFO, onResponse=onResponse)
logging.info("Starting power stress test, attempting to contact UUT...")
self.client.sendPowerStress(
powermon_pb2.PowerStressMessage.PRINT_INFO, onResponse=onResponse
)
# Wait for the response
while not gotAck:
time.sleep(0.1)
logging.info("Power stress test complete.")
logging.info("Power stress test complete.")

View File

@@ -4,7 +4,7 @@ import logging
import os
import pyarrow as pa
import pyarrow.feather as feather
from pyarrow import feather
chunk_size = 1000 # disk writes are batched based on this number of rows

View File

@@ -118,7 +118,8 @@ class StructuredLogger:
self.writer.close()
f = self.raw_file
self.raw_file = None # mark that we are shutting down
f.close() # Close the raw.txt file
if f:
f.close() # Close the raw.txt file
def _onLogMessage(self, line: str) -> None:
"""Handle log messages.