Skip to content

Commit

Permalink
fixed get logs function
Browse files Browse the repository at this point in the history
  • Loading branch information
rclarke0 committed Apr 9, 2024
1 parent 8cd4438 commit ccdd1da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion abr-testing/abr_testing/data_collection/abr_lpc.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Get LPC Values from Run logs and pair with calibration."""
"""Get Unique LPC Values from Run logs."""
25 changes: 16 additions & 9 deletions abr-testing/abr_testing/data_collection/read_robot_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,21 @@ def get_logs(storage_directory: str, ip: str) -> List[str]:
log_types = ["api.log", "server.log", "serial.log", "touchscreen.log"]
all_paths = []
for log_type in log_types:
response = requests.get(
f"http://{ip}:31950/logs",
headers={"log_identifier": log_type},
params={"cursor": 0, "pageLength": 0},
)
log_name = ip + "_" + log_type.split(".")[0] + ".json"
log_data = response.json()
file_path = os.path.join(storage_directory, log_name)
json.dump(log_data, open(file_path, mode="w"))
try:
response = requests.get(
f"http://{ip}:31950/logs/{log_type}",
headers={"log_identifier": log_type},
params={"records": 5000},
)
response.raise_for_status()
log_data = response.text
log_name = ip + "_" + log_type.split(".")[0] + ".json"
file_path = os.path.join(storage_directory, log_name)
with open(file_path, mode="w", encoding="utf-8") as file:
file.write(response.text)
json.dump(log_data, open(file_path, mode="w"))
except RuntimeError:
print(f"Request exception. Did not save {log_type}")
continue
all_paths.append(file_path)
return all_paths

0 comments on commit ccdd1da

Please sign in to comment.