def delete_substep_on_disk(substep) -> InternalOperationResult: client = FileSystemClient() cam_removing_info = client.remove_file(substep.os_path) if cam_removing_info.status is not ExecutionStatus.SUCCESS: return cam_removing_info screencast_removing_info = client.remove_file(substep.os_screencast_path) if screencast_removing_info.status is not ExecutionStatus.SUCCESS: return screencast_removing_info raw_cut_removing_info = client.remove_file(substep.os_automontage_file) if raw_cut_removing_info.status is not ExecutionStatus.SUCCESS: return raw_cut_removing_info return InternalOperationResult(ExecutionStatus.SUCCESS)
class FileRemover(PostprocessorInterface): def __init__(self): self.fs_client = FileSystemClient() self.logger = logging.getLogger(__name__) def process(self, path: str, filename: str) -> (str, str): file_to_remove = os.path.splitext(filename)[0] + TS_EXTENSION path = os.path.join(path, file_to_remove) if not os.path.isfile(path): self.logger.warning( 'Removing %s file failed: file %s is not valid.', TS_EXTENSION, path) return path, filename remove_status = self.fs_client.remove_file(path) if remove_status.status is not ExecutionStatus.SUCCESS: self.logger.error('Removing file %s failed: %s', path, remove_status.message) return path, filename
def __exit__(self, *exc_info): self.wave_form.close() FileSystemClient.remove_file(self.audio_path)