def DeleteLocalDir(basedir, pathID): """ Remove local sub folder at given `basedir` root path. """ if not pathIsDir(basedir): raise Exception('Directory not exist: %s' % basedir) path = os.path.join(basedir, pathID) if not os.path.exists(path): return if not pathIsDir(path): raise Exception('Error, %s is not a directory' % path) dhnio.rmdir_recursive(path, ignore_errors=True)
def DeleteLocalBackup(basedir, backupID): """ Remove local files for that backup. """ count_and_size = [0, 0,] if not pathIsDir(basedir): raise Exception('Directory not exist: %s' % basedir) backupDir = os.path.join(basedir, backupID) if not pathExist(backupDir): return count_and_size[0], count_and_size[1] if not pathIsDir(backupDir): raise Exception('Error, %s is not a directory' % backupDir) def visitor(fullpath): if os.path.isfile(fullpath): count_and_size[0] += 1 count_and_size[1] += os.path.getsize(fullpath) return True dhnio.rmdir_recursive(backupDir, ignore_errors=True, pre_callback=visitor) return count_and_size[0], count_and_size[1]