Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2015-04-02 18:52:40 +0200
committerArthur de Jong <arthur@arthurdejong.org>2015-04-02 23:43:31 +0200
commit621e9d699882b4ef4a6e72324ecc8dd1310d16d1 (patch)
tree9aa34d832240d6bb8aff0bf7cc27207bac81d3c3
parent574b93049b33a5642c4f8181a295e6ab3b2e7904 (diff)
Ingore errors in crawling directories
-rw-r--r--crawler.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/crawler.py b/crawler.py
index 32b0e5b..3f36bc8 100644
--- a/crawler.py
+++ b/crawler.py
@@ -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=()):