From 6d2a187d38acfe36415467940c5d794275574aaf Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Mon, 6 Dec 2021 23:01:34 -0800 Subject: [PATCH] fix pylint warnings --- meshtastic/__init__.py | 1 - meshtastic/ble_interface.py | 2 ++ meshtastic/mesh_interface.py | 12 ++++++++---- meshtastic/remote_hardware.py | 6 ++++-- meshtastic/serial_interface.py | 4 +++- meshtastic/stream_interface.py | 12 +++++------- meshtastic/tcp_interface.py | 6 ++++-- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py index 5e76cf9..629351d 100644 --- a/meshtastic/__init__.py +++ b/meshtastic/__init__.py @@ -171,4 +171,3 @@ protocols = { portnums_pb2.PortNum.REMOTE_HARDWARE_APP: KnownProtocol( "remotehw", remote_hardware_pb2.HardwareMessage) } - diff --git a/meshtastic/ble_interface.py b/meshtastic/ble_interface.py index 1ffe75f..863627d 100644 --- a/meshtastic/ble_interface.py +++ b/meshtastic/ble_interface.py @@ -1,3 +1,5 @@ +""" Bluetooth interface +""" import logging import pygatt diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index c19ea8f..e468dd4 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -1,17 +1,19 @@ +""" Mesh Interface class +""" import sys import random import time import logging -import timeago from typing import AnyStr import threading +from datetime import datetime +import timeago from tabulate import tabulate import google.protobuf.json_format from pubsub import pub from google.protobuf.json_format import MessageToJson -from datetime import datetime from . import portnums_pb2, mesh_pb2 @@ -438,11 +440,13 @@ class MeshInterface: failmsg = None # Check for app too old if self.myInfo.min_app_version > OUR_APP_VERSION: - failmsg = "This device needs a newer python client, please \"pip install --upgrade meshtastic\". For more information see https://tinyurl.com/5bjsxu32" + failmsg = "This device needs a newer python client, please \"pip install --upgrade meshtastic\". "\ + "For more information see https://tinyurl.com/5bjsxu32" # check for firmware too old if self.myInfo.max_channels == 0: - failmsg = "This version of meshtastic-python requires device firmware version 1.2 or later. For more information see https://tinyurl.com/5bjsxu32" + failmsg = "This version of meshtastic-python requires device firmware version 1.2 or later. "\ + "For more information see https://tinyurl.com/5bjsxu32" if failmsg: self.failure = Exception(failmsg) diff --git a/meshtastic/remote_hardware.py b/meshtastic/remote_hardware.py index 10ac8c5..4357607 100644 --- a/meshtastic/remote_hardware.py +++ b/meshtastic/remote_hardware.py @@ -1,4 +1,5 @@ - +""" Remote hardware +""" from pubsub import pub from . import portnums_pb2, remote_hardware_pb2 @@ -28,7 +29,8 @@ class RemoteHardwareClient: ch = iface.localNode.getChannelByName("gpio") if not ch: raise Exception( - "No gpio channel found, please create on the sending and receive nodes to use this (secured) service (--ch-add gpio --info then --seturl)") + "No gpio channel found, please create on the sending and receive nodes "\ + "to use this (secured) service (--ch-add gpio --info then --seturl)") self.channelIndex = ch.index pub.subscribe( diff --git a/meshtastic/serial_interface.py b/meshtastic/serial_interface.py index 91a26ef..04e2fff 100644 --- a/meshtastic/serial_interface.py +++ b/meshtastic/serial_interface.py @@ -1,8 +1,10 @@ +""" Serial interface class +""" import logging -import serial import platform import os import stat +import serial from .stream_interface import StreamInterface from .util import findPorts diff --git a/meshtastic/stream_interface.py b/meshtastic/stream_interface.py index aa6d920..a7ce471 100644 --- a/meshtastic/stream_interface.py +++ b/meshtastic/stream_interface.py @@ -1,16 +1,14 @@ +""" Stream Interface base class +""" import logging import threading import time import traceback import serial -import timeago - -from tabulate import tabulate from .mesh_interface import MeshInterface from .util import stripnl -from .__init__ import LOCAL_ADDR, BROADCAST_NUM START1 = 0x94 @@ -87,9 +85,9 @@ class StreamInterface(MeshInterface): self.stream.write(b) self.stream.flush() - def _readBytes(self, len): + def _readBytes(self, length): """Read an array of bytes from our stream""" - return self.stream.read(len) + return self.stream.read(length) def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" @@ -129,7 +127,7 @@ class StreamInterface(MeshInterface): if ptr == 0: # looking for START1 if c != START1: self._rxBuf = empty # failed to find start - if self.debugOut != None: + if self.debugOut is not None: try: self.debugOut.write(b.decode("utf-8")) except: diff --git a/meshtastic/tcp_interface.py b/meshtastic/tcp_interface.py index 5bdaf13..9116999 100644 --- a/meshtastic/tcp_interface.py +++ b/meshtastic/tcp_interface.py @@ -1,3 +1,5 @@ +""" TCPInterface class for interfacing with http endpoint +""" import logging import socket from typing import AnyStr @@ -45,6 +47,6 @@ class TCPInterface(StreamInterface): """Write an array of bytes to our stream and flush""" self.socket.send(b) - def _readBytes(self, len): + def _readBytes(self, length): """Read an array of bytes from our stream""" - return self.socket.recv(len) + return self.socket.recv(length)