Linting, minor fixes

This commit is contained in:
madrigal 2025-09-19 09:41:03 -04:00
parent 5e10cefc62
commit 1fc33eb6f4
2 changed files with 28 additions and 24 deletions

View File

@ -159,18 +159,17 @@ def add_distance_after(filename: str, base_location: dict):
with open(filename, "r") as file:
data = json.load(file)
except FileNotFoundError:
print('No file by that name')
print("No file by that name")
return None
distance = 'Unknown'
distance = "Unknown"
for dictionary in data:
if 'latitude' in dictionary:
# dictionary['longitude'] = fix_long(dictionary['longitude'])
if "latitude" in dictionary and type(dictionary["latitude"]) == float:
distance = calculate_distance(base_location, dictionary)
dictionary["distance"] = distance
elif 'iperf_full' in dictionary:
dictionary['start_distance'] = distance
elif "iperf_full" in dictionary:
dictionary["start_distance"] = distance
# Save updated data back to the file
with open(filename, "w") as file:
@ -178,10 +177,15 @@ def add_distance_after(filename: str, base_location: dict):
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 = {
'latitude': 43.656328,
'longitude': -79.307884,
'altitude': 80,
"latitude": 43.656328,
"longitude": -79.307884,
"altitude": 80,
}
for filename in filenames:
add_distance_after(filename=filename, base_location=base_location)