Skip to content

Commit

Permalink
feat(abr-testing): Download Weston log during error recording (#15526)
Browse files Browse the repository at this point in the history
<!--
Thanks for taking the time to open a pull request! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview

Uses scp command to download weston.log during error recording.

# Test Plan

<!--
Use this section to describe the steps that you took to test your Pull
Request.
If you did not perform any testing provide justification why.

OT-3 Developers: You should default to testing on actual physical
hardware.
Once again, if you did not perform testing against hardware, justify
why.

Note: It can be helpful to write a test plan before doing development

Example Test Plan (HTTP API Change)

- Verified that new optional argument `dance-party` causes the robot to
flash its lights, move the pipettes,
then home.
- Verified that when you omit the `dance-party` option the robot homes
normally
- Added protocol that uses `dance-party` argument to G-Code Testing
Suite
- Ran protocol that did not use `dance-party` argument and everything
was successful
- Added unit tests to validate that changes to pydantic model are
correct

-->

# Changelog

<!--
List out the changes to the code in this PR. Please try your best to
categorize your changes and describe what has changed and why.

Example changelog:
- Fixed app crash when trying to calibrate an illegal pipette
- Added state to API to track pipette usage
- Updated API docs to mention only two pipettes are supported

IMPORTANT: MAKE SURE ANY BREAKING CHANGES ARE PROPERLY COMMUNICATED
-->

# Review requests

<!--
Describe any requests for your reviewers here.
-->

# Risk assessment

<!--
Carefully go over your pull request and look at the other parts of the
codebase it may affect. Look for the possibility, even if you think it's
small, that your change may affect some other part of the system - for
instance, changing return tip behavior in protocol may also change the
behavior of labware calibration.

Identify the other parts of the system your codebase may affect, so that
in addition to your own review and testing, other people who may not
have the system internalized as much as you can focus their attention
and testing there.
-->
  • Loading branch information
rclarke0 authored Jun 26, 2024
1 parent ce86430 commit 5e5b9b1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions abr-testing/abr_testing/data_collection/read_robot_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
saved in a local directory.
"""
import csv
import subprocess
from datetime import datetime
import os
from abr_testing.data_collection.error_levels import ERROR_LEVELS_PATH
Expand Down Expand Up @@ -587,4 +588,30 @@ def get_logs(storage_directory: str, ip: str) -> List[str]:
print(f"Request exception. Did not save {log_type}")
continue
all_paths.append(file_path)
# Get weston.log using scp
# Split the path into parts
parts = storage_directory.split(os.sep)
# Find the index of 'Users'
index = parts.index("Users")
user_name = parts[index + 1]
# Define the SCP command
scp_command = [
"scp",
"-r",
"-i",
f"C:\\Users\\{user_name}\\.ssh\\robot_key",
f"root@{ip}:/var/log/weston.log",
storage_directory,
]
# Execute the SCP command
try:
subprocess.run(scp_command, check=True, capture_output=True, text=True)
file_path = os.path.join(storage_directory, "weston.log")
all_paths.append(file_path)
except subprocess.CalledProcessError as e:
print("Error during SCP command execution")
print("Return code:", e.returncode)
print("Output:", e.output)
print("Error output:", e.stderr)
subprocess.run(["scp", "weston.log", "[email protected]:/var/log/weston.log"])
return all_paths

0 comments on commit 5e5b9b1

Please sign in to comment.