Linting, minor fixes
This commit is contained in:
parent
5e10cefc62
commit
1fc33eb6f4
|
@ -49,7 +49,7 @@ def get_modem_cops(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["cops error"] = f"{e}"
|
dictionary["cops error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ def get_modem_creg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["creg error"] = f"{e}"
|
dictionary["creg error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ def get_modem_csq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["csq error"] = f"{e}"
|
dictionary["csq error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ def get_modem_rsrp(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["qrsrp error"] = f"{e}"
|
dictionary["qrsrp error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ def get_modem_rsrq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["qrsrq error"] = f"{e}"
|
dictionary["qrsrq error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ def get_modem_sinr(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["qsinr error"] = f"{e}"
|
dictionary["qsinr error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ def get_modem_cpol(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["cpol error"] = f"{e}"
|
dictionary["cpol error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ def get_modem_qnwcfg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["qnwcfg error"] = f"{e}"
|
dictionary["qnwcfg error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ def get_modem_qnwinfo(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["qnwinfo error"] = f"{e}"
|
dictionary["qnwinfo error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,5 +366,5 @@ def get_modem_qspn(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dictionary["qspn error"] = f"{e}"
|
dictionary["qspn error"] = f"{e}"
|
||||||
|
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
|
@ -134,7 +134,7 @@ def save_data_to_json(data, filename):
|
||||||
def fix_long(bad_long):
|
def fix_long(bad_long):
|
||||||
"""
|
"""
|
||||||
Fix longitude values incorrectly parsed from NMEA (leading zero dropped degrees).
|
Fix longitude values incorrectly parsed from NMEA (leading zero dropped degrees).
|
||||||
|
|
||||||
Assumes all values should be around -79.x based on recording location.
|
Assumes all values should be around -79.x based on recording location.
|
||||||
Removes the spurious leading digit from minutes.
|
Removes the spurious leading digit from minutes.
|
||||||
"""
|
"""
|
||||||
|
@ -159,18 +159,17 @@ def add_distance_after(filename: str, base_location: dict):
|
||||||
with open(filename, "r") as file:
|
with open(filename, "r") as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print('No file by that name')
|
print("No file by that name")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
distance = 'Unknown'
|
distance = "Unknown"
|
||||||
|
|
||||||
for dictionary in data:
|
for dictionary in data:
|
||||||
if 'latitude' in dictionary:
|
if "latitude" in dictionary and type(dictionary["latitude"]) == float:
|
||||||
# dictionary['longitude'] = fix_long(dictionary['longitude'])
|
|
||||||
distance = calculate_distance(base_location, dictionary)
|
distance = calculate_distance(base_location, dictionary)
|
||||||
dictionary["distance"] = distance
|
dictionary["distance"] = distance
|
||||||
elif 'iperf_full' in dictionary:
|
elif "iperf_full" in dictionary:
|
||||||
dictionary['start_distance'] = distance
|
dictionary["start_distance"] = distance
|
||||||
|
|
||||||
# Save updated data back to the file
|
# Save updated data back to the file
|
||||||
with open(filename, "w") as file:
|
with open(filename, "w") as file:
|
||||||
|
@ -178,10 +177,15 @@ def add_distance_after(filename: str, base_location: dict):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
filename = '/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758123903_copy.json'
|
filenames = [
|
||||||
|
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758215714_copy.json",
|
||||||
|
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758217711_copy.json",
|
||||||
|
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758219350_copy.json"
|
||||||
|
]
|
||||||
base_location = {
|
base_location = {
|
||||||
'latitude': 43.656328,
|
"latitude": 43.656328,
|
||||||
'longitude': -79.307884,
|
"longitude": -79.307884,
|
||||||
'altitude': 80,
|
"altitude": 80,
|
||||||
}
|
}
|
||||||
add_distance_after(filename=filename, base_location=base_location)
|
for filename in filenames:
|
||||||
|
add_distance_after(filename=filename, base_location=base_location)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user