-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(abr-testing): Download weston log during error recording
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |