Improved telemetry fabrication logging and failing if telemetry folders don't exist

This commit is contained in:
VakarisZ 2020-05-11 16:56:05 +03:00
parent e189e96259
commit 67b7d0b769
2 changed files with 8 additions and 5 deletions

View File

@ -30,8 +30,12 @@ class SampleFileParser:
@staticmethod @staticmethod
def read_telem_files() -> List[str]: def read_telem_files() -> List[str]:
telems = [] telems = []
try:
file_paths = [path.join(TELEM_DIR_PATH, f) for f in listdir(TELEM_DIR_PATH) file_paths = [path.join(TELEM_DIR_PATH, f) for f in listdir(TELEM_DIR_PATH)
if path.isfile(path.join(TELEM_DIR_PATH, f))] if path.isfile(path.join(TELEM_DIR_PATH, f))]
except FileNotFoundError:
raise FileNotFoundError("Telemetries to send not found. "
"Refer to readme to figure out how to generate telemetries and where to put them.")
for file_path in file_paths: for file_path in file_paths:
with open(file_path, 'r') as telem_file: with open(file_path, 'r') as telem_file:
telem_string = "".join(telem_file.readlines()).replace("\n", "") telem_string = "".join(telem_file.readlines()).replace("\n", "")

View File

@ -26,9 +26,8 @@ class TelemetryPerformanceTest:
try: try:
all_telemetries = SampleFileParser.get_all_telemetries() all_telemetries = SampleFileParser.get_all_telemetries()
except FileNotFoundError: except FileNotFoundError:
LOGGER.error("Telemetries to send not found. Refer to readme to figure out how to generate telemetries " raise FileNotFoundError("Telemetries to send not found. "
"and where to put them.") "Refer to readme to figure out how to generate telemetries and where to put them.")
return False
LOGGER.info("Telemetries imported successfully.") LOGGER.info("Telemetries imported successfully.")
all_telemetries.sort(key=lambda telem: telem['time']['$date']) all_telemetries.sort(key=lambda telem: telem['time']['$date'])
telemetry_parse_times = {} telemetry_parse_times = {}