2022-08-24 15:01:07 +00:00
|
|
|
import traceback
|
|
|
|
|
2023-01-10 13:02:24 +00:00
|
|
|
from frostfs_testlib.shell.interfaces import CommandResult
|
2022-08-24 11:41:11 +00:00
|
|
|
|
2022-08-24 15:01:07 +00:00
|
|
|
|
|
|
|
def format_error_details(error: Exception) -> str:
|
2022-10-05 09:14:51 +00:00
|
|
|
"""Converts specified exception instance into a string.
|
|
|
|
|
|
|
|
The resulting string includes error message and the full stack trace.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
error: Exception to convert.
|
2022-08-24 11:41:11 +00:00
|
|
|
|
2022-10-05 09:14:51 +00:00
|
|
|
Returns:
|
|
|
|
String containing exception details.
|
2022-08-24 11:41:11 +00:00
|
|
|
"""
|
2023-07-18 17:38:37 +00:00
|
|
|
detail_lines = traceback.format_exception(error)
|
2022-08-24 11:41:11 +00:00
|
|
|
return "".join(detail_lines)
|
|
|
|
|
|
|
|
|
|
|
|
def get_output_lines(result: CommandResult) -> list[str]:
|
2022-10-05 09:14:51 +00:00
|
|
|
"""Converts output of specified command result into separate lines.
|
|
|
|
|
|
|
|
Whitespaces are trimmed, empty lines are excluded.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
result: Command result which output should be converted.
|
2022-08-24 11:41:11 +00:00
|
|
|
|
2022-10-05 09:14:51 +00:00
|
|
|
Returns:
|
|
|
|
List of lines extracted from the output.
|
2022-08-24 11:41:11 +00:00
|
|
|
"""
|
|
|
|
return [line.strip() for line in result.stdout.split("\n") if line.strip()]
|