def write_permacache_from_dir(dirname): # we want the whole list so that we can display accurate progress # information. If we're operating on more than tens of millions of # files, we should either bail out or tweak this to not need the # whole list at once allfiles = [] for root, dirs, files in os.walk(dirname): for f in files: allfiles.append(os.path.join(root, f)) for fname in progress(allfiles, persec=True): try: write_permacache_from_file(fname) os.unlink(fname) except: mr_tools.status("failed on %r" % fname) raise mr_tools.status("Removing empty directories") for root, dirs, files in os.walk(dirname, topdown=False): for d in dirs: dname = os.path.join(root, d) try: os.rmdir(dname) except OSError as e: if e.errno == errno.ENOTEMPTY: mr_tools.status("%s not empty" % (dname,)) else: raise
def write_permacache_from_dir(dirname): for fname in progress(os.listdir(dirname), persec=True): try: fpath = os.path.join(dirname, fname) write_permacache_from_file(fpath) os.unlink(fpath) except: mr_tools.status('failed on %r' % fname) raise
def write_permacache_from_dir(dirname): # we want the whole list so that we can display accurate progress # information. If we're operating on more than tens of millions of # files, we should either bail out or tweak this to not need the # whole list at once allfiles = [] for root, dirs, files in os.walk(dirname): for f in files: allfiles.append(os.path.join(root, f)) for fname in progress(allfiles, persec=True): try: write_permacache_from_file(fname) os.unlink(fname) except: mr_tools.status('failed on %r' % fname) raise mr_tools.status('Removing empty directories') for root, dirs, files in os.walk(dirname, topdown=False): for d in dirs: dname = os.path.join(root, d) try: os.rmdir(dname) except OSError as e: if e.errno == errno.ENOTEMPTY: mr_tools.status('%s not empty' % (dname, )) else: raise