Skip to content

Commit

Permalink
fix linter warnings
Browse files Browse the repository at this point in the history
(note: the linter test for min/max is buggy so disabled)
  • Loading branch information
geeksville committed Jul 3, 2024
1 parent 2f5a736 commit ae2ef78
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
5 changes: 2 additions & 3 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def setSimpleConfig(modem_preset):

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)

Check warning on line 858 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L858

Added line #L858 was not covered by tests

if args.power_stress:
Expand Down Expand Up @@ -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)

Check warning on line 1007 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L1007

Added line #L1007 was not covered by tests
elif args.power_ppk2_supply or args.power_ppk2_meter:
Expand Down
2 changes: 1 addition & 1 deletion meshtastic/powermon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .ppk2 import PPK2PowerSupply
from .riden import RidenPowerSupply
from .sim import SimPowerSupply
from .stress import PowerStress
from .stress import PowerStress
5 changes: 3 additions & 2 deletions meshtastic/powermon/ppk2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

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.
Expand Down Expand Up @@ -130,7 +129,9 @@ def setIsSupply(self, s: bool):
# must be after setting source voltage and before setting mode
self.r.start_measuring() # send command to ppk2

Check warning on line 130 in meshtastic/powermon/ppk2.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/ppk2.py#L130

Added line #L130 was not covered by tests

if not s: # min power outpuf of PPK2. If less than this assume we want just meter mode.
if (

Check warning on line 132 in meshtastic/powermon/ppk2.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/ppk2.py#L132

Added line #L132 was not covered by tests
not s
): # min power outpuf of PPK2. If less than this assume we want just meter mode.
self.r.use_ampere_meter()

Check warning on line 135 in meshtastic/powermon/ppk2.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/ppk2.py#L135

Added line #L135 was not covered by tests
else:
self.r.use_source_meter() # set source meter mode

Check warning on line 137 in meshtastic/powermon/ppk2.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/ppk2.py#L137

Added line #L137 was not covered by tests
Expand Down
29 changes: 16 additions & 13 deletions meshtastic/powermon/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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.
Expand All @@ -31,14 +28,18 @@ def __init__(self, iface, node_id = None):
if not node_id:
node_id = iface.myInfo.my_node_num

Check warning on line 29 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L28-L29

Added lines #L28 - L29 were not covered by tests

self.node_id = node_id
self.node_id = node_id

Check warning on line 31 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L31

Added line #L31 was not covered by tests
# 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

Check warning on line 44 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L42-L44

Added lines #L42 - L44 were not covered by tests

Expand All @@ -49,16 +50,16 @@ def sendPowerStress(
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)

Check warning on line 61 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L61

Added line #L61 was not covered by tests


def run(self):
"""Run the power stress test."""
# Send the power stress command
Expand All @@ -68,11 +69,13 @@ def onResponse(packet: dict): # pylint: disable=unused-argument
nonlocal gotAck
gotAck = True

Check warning on line 70 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L70

Added line #L70 was not covered by tests

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(

Check warning on line 73 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L72-L73

Added lines #L72 - L73 were not covered by tests
powermon_pb2.PowerStressMessage.PRINT_INFO, onResponse=onResponse
)

# Wait for the response
while not gotAck:
time.sleep(0.1)

Check warning on line 79 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L78-L79

Added lines #L78 - L79 were not covered by tests

logging.info("Power stress test complete.")
logging.info("Power stress test complete.")

Check warning on line 81 in meshtastic/powermon/stress.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/powermon/stress.py#L81

Added line #L81 was not covered by tests
2 changes: 1 addition & 1 deletion meshtastic/slog/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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

Expand Down
3 changes: 2 additions & 1 deletion meshtastic/slog/slog.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def close(self) -> None:
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

Check warning on line 122 in meshtastic/slog/slog.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/slog/slog.py#L117-L122

Added lines #L117 - L122 were not covered by tests

def _onLogMessage(self, line: str) -> None:
"""Handle log messages.
Expand Down

0 comments on commit ae2ef78

Please sign in to comment.