From ea947523b36211fbc73fc51c971f44794fd38d46 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 21 Mar 2022 13:38:04 +0530 Subject: [PATCH] fix(find): Handle OS' PermissionError --- bench/utils/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bench/utils/__init__.py b/bench/utils/__init__.py index dde12acc..9c8d98a4 100644 --- a/bench/utils/__init__.py +++ b/bench/utils/__init__.py @@ -314,7 +314,13 @@ def find_benches(directory: str = None) -> List: return benches = [] - for sub in os.listdir(directory): + + try: + sub_directories = os.listdir(directory) + except PermissionError: + return benches + + for sub in sub_directories: sub = os.path.join(directory, sub) if os.path.isdir(sub) and not os.path.islink(sub): if is_bench_directory(sub):