diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2015-04-02 18:52:40 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2015-04-02 23:43:31 +0200 |
commit | 621e9d699882b4ef4a6e72324ecc8dd1310d16d1 (patch) | |
tree | 9aa34d832240d6bb8aff0bf7cc27207bac81d3c3 | |
parent | 574b93049b33a5642c4f8181a295e6ab3b2e7904 (diff) |
Ingore errors in crawling directories
-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=()): |