def rm(self, cert, file_id): """Removes a file given its id""" import logging from libviri.objects import File if File.exists(self.db, file_id): logging.info('File {} removed'.format(file_id)) File.delete(self.db, {'file_id': file_id}) return (SUCCESS, 'File successfully removed') else: return (ERROR, 'File not found')
def mv(self, cert, file_id, new_file_name): """Renames file with the given id""" import logging from libviri.objects import File if File.exists(self.db, file_id): logging.info('File {} renamed to {}'.format( file_id, new_file_name)) File.update(self.db, {'file_name': new_file_name}, {'file_id': file_id}) return (SUCCESS, 'File successfully renamed') else: return (ERROR, 'File not found')
def mv(self, cert, file_id, new_file_name): """Renames file with the given id""" import logging from libviri.objects import File if File.exists(self.db, file_id): logging.info('File {} renamed to {}'.format(file_id, new_file_name)) File.update(self.db, {'file_name': new_file_name}, {'file_id': file_id}) return (SUCCESS, 'File successfully renamed') else: return (ERROR, 'File not found')
def exists(self, cert, file_id): """Returns True if a file with the given id exists.""" from libviri.objects import File return (SUCCESS, File.exists(self.db, file_id))