Utils
- src.utils.filehandlingutils.cleanup_local_sensor_output_directory(sensor_dir: str)[source]
Iterates through the directory and removes all empty ‘date’ directories that are empty and have a date prior to the current date(timezone aware).
- Parameters:
sensor_dir (str) – The directory to be cleaned.
- src.utils.filehandlingutils.write_sensor_csv_file(start_time_queue: Queue, file_path: str, data: list)[source]
- This function is used to write .csv files for the sensors after they gather their data. The function checks whether
it is the last recording of the day. If it is not the last recording, it simply appends to the .csv file. If it is the last recording of the day the file is read and all the contents of the file are written to a new file with the same path but .final appended to the end of the filename. THis tags the file as being the final recording of the day. When the uploader uploads the .final file, it will also remove the .csv file.
- Parameters:
start_time_queue (Queue) – The queue that defines the starting times of the recordings. This is used to check if it is the last recording of the day.
file_path (str) – The path to which the file should be written. If that file exists it the data will be appended to the end of the file.
data (list) – A list that contains the data to add to the .csv file. Each element of the list is separated by a comma and written to the CSV as one row.
- Raises:
FileNotFoundError – File at given
file_path
orfile_path.final
may not exist.