Merge pull request #353 from Douile/dev-fix-lint-errors-2

Fix lint errors
This commit is contained in:
Ben Meadors
2022-08-05 10:13:58 -05:00
committed by GitHub
2 changed files with 12 additions and 10 deletions

View File

@@ -85,6 +85,7 @@ def getPref(config, comp_name):
return True
def splitCompoundName(comp_name):
"""Split compound (dot separated) preference name into parts"""
name = comp_name.split(".",1)
if len(name) != 2:
name[0]=comp_name
@@ -115,7 +116,7 @@ def setPref(config, comp_name, valStr):
if snake_name == 'psk' and len(valStr) < 8:
print(f"Warning: wifi.psk must be 8 or more characters.")
return
return False
enumType = pref.enum_type
# pylint: disable=C0123
@@ -136,7 +137,7 @@ def setPref(config, comp_name, valStr):
names.append(f'{f.name}')
for temp_name in sorted(names):
print(f" {temp_name}")
return
return False
# note: 'ignore_incoming' is a repeating field
if snake_name != 'ignore_incoming':
@@ -160,7 +161,7 @@ def setPref(config, comp_name, valStr):
print(f"Set {name[0]}.{camel_name} to {valStr}")
else:
print(f"Set {name[0]}.{snake_name} to {valStr}")
return True
@@ -327,6 +328,7 @@ def onConnected(interface):
node = interface.getNode(args.dest)
# Handle the int/float/bool arguments
pref = None
for pref in args.set:
found = setPref(node.localConfig, pref[0], pref[1])
if not found:
@@ -337,7 +339,7 @@ def onConnected(interface):
interface.getNode(args.dest).writeConfig()
else:
if Globals.getInstance().get_camel_case():
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
else:
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
@@ -546,7 +548,7 @@ def onConnected(interface):
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
else:
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
print("Completed getting preferences")
if args.nodes:

View File

@@ -532,17 +532,17 @@ class MeshInterface:
# stream API fromRadio.config_complete_id
logging.debug(f"Config complete ID {self.configId}")
self._handleConfigComplete()
elif fromRadio.HasField("packet"):
self._handlePacketFromRadio(fromRadio.packet)
elif fromRadio.rebooted:
# Tell clients the device went away. Careful not to call the overridden
# subclass version that closes the serial port
MeshInterface._disconnected(self)
self._startConfig() # redownload the node db etc...
elif fromRadio.config or fromRadio.moduleConfig:
if fromRadio.config.HasField("device"):
self.localNode.localConfig.device.CopyFrom(fromRadio.config.device)
@@ -556,7 +556,7 @@ class MeshInterface:
self.localNode.localConfig.display.CopyFrom(fromRadio.config.display)
elif fromRadio.config.HasField("lora"):
self.localNode.localConfig.lora.CopyFrom(fromRadio.config.lora)
elif fromRadio.moduleConfig.HasField("mqtt"):
self.localNode.moduleConfig.mqtt.CopyFrom(fromRadio.moduleConfig.mqtt)
elif fromRadio.moduleConfig.HasField("serial"):
@@ -569,7 +569,7 @@ class MeshInterface:
self.localNode.moduleConfig.telemetry.CopyFrom(fromRadio.moduleConfig.telemetry)
elif fromRadio.moduleConfig.HasField("canned_message"):
self.localNode.moduleConfig.canned_message.CopyFrom(fromRadio.moduleConfig.canned_message)
else:
logging.debug("Unexpected FromRadio payload")