diff options
-rw-r--r-- | crawler.py | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -72,11 +72,17 @@ def walk(top, path_excludes, dir_excludes): print('%r %r' % (top, name)) # recurse into directories for name in dirs: - os.chdir(name) - for path, size, is_dir, meta in walk(os.path.join(top, name), - path_excludes, dir_excludes): - yield path, size, is_dir, meta - os.chdir('..') + try: + os.chdir(name) + except (UnicodeDecodeError, OSError): + import traceback + print(traceback.format_exc()) + print('%r %r' % (top, name)) + else: + for path, size, is_dir, meta in walk(os.path.join(top, name), + path_excludes, dir_excludes): + yield path, size, is_dir, meta + os.chdir('..') def crawl(paths, excludes=()): |