Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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=()):