mirror of
https://github.com/meshtastic/python.git
synced 2026-01-02 04:47:54 -05:00
Rename "retries" to "attempts"
Otherwise, semantically, it's off-by-one.
This commit is contained in:
@@ -275,7 +275,7 @@ def onConnected(interface):
|
||||
|
||||
# convenient place to store any keyword args we pass to getNode
|
||||
getNode_kwargs = {
|
||||
"requestChannelRetries": args.channel_fetch_retries,
|
||||
"requestChannelRetries": args.channel_fetch_attempts,
|
||||
"timeout": args.timeout
|
||||
}
|
||||
|
||||
@@ -1416,7 +1416,7 @@ def initParser():
|
||||
)
|
||||
|
||||
group.add_argument(
|
||||
"--channel-fetch-retries",
|
||||
"--channel-fetch-attempts",
|
||||
help=("Attempt to retrieve channel settings for --ch-set this many times before giving up."),
|
||||
default=3,
|
||||
type=int,
|
||||
|
||||
@@ -315,7 +315,7 @@ class MeshInterface: # pylint: disable=R0902
|
||||
return table
|
||||
|
||||
def getNode(
|
||||
self, nodeId: str, requestChannels: bool = True, requestChannelRetries: int = 3, timeout: int = 300
|
||||
self, nodeId: str, requestChannels: bool = True, requestChannelAttempts: int = 3, timeout: int = 300
|
||||
) -> meshtastic.node.Node:
|
||||
"""Return a node object which contains device settings and channel info"""
|
||||
if nodeId in (LOCAL_ADDR, BROADCAST_ADDR):
|
||||
@@ -326,7 +326,7 @@ class MeshInterface: # pylint: disable=R0902
|
||||
if requestChannels:
|
||||
logging.debug("About to requestChannels")
|
||||
n.requestChannels()
|
||||
retries_left = requestChannelRetries
|
||||
retries_left = requestChannelAttempts
|
||||
last_index: int = 0
|
||||
while retries_left > 0:
|
||||
retries_left -= 1
|
||||
@@ -334,7 +334,7 @@ class MeshInterface: # pylint: disable=R0902
|
||||
new_index: int = len(n.partialChannels) if n.partialChannels else 0
|
||||
# each time we get a new channel, reset the counter
|
||||
if new_index != last_index:
|
||||
retries_left = requestChannelRetries - 1
|
||||
retries_left = requestChannelAttempts - 1
|
||||
if retries_left <= 0:
|
||||
our_exit(f"Error: Timed out waiting for channels, giving up")
|
||||
print("Timed out trying to retrieve channel info, retrying")
|
||||
|
||||
Reference in New Issue
Block a user