Skip to content
Snippets Groups Projects
Commit 4cb581b3 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

fix for OSErrors

parent da478ecb
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,8 @@ import os ...@@ -4,6 +4,8 @@ import os
import sys import sys
import warnings import warnings
from satella.coding import silence_excs
def whereis(name: str) -> tp.Iterator[str]: def whereis(name: str) -> tp.Iterator[str]:
""" """
...@@ -25,17 +27,18 @@ def whereis(name: str) -> tp.Iterator[str]: ...@@ -25,17 +27,18 @@ def whereis(name: str) -> tp.Iterator[str]:
available_extensions = '', available_extensions = '',
for directory in paths_to_look_in: for directory in paths_to_look_in:
for file in os.listdir(directory): with silence_excs(FileNotFoundError):
path = os.path.join(directory, file) for file in os.listdir(directory):
if 'x' not in stat.filemode(os.stat(path).st_mode): path = os.path.join(directory, file)
continue if 'x' not in stat.filemode(os.stat(path).st_mode):
continue
if sys.platform.startswith('win'): # a POSIX-specific check
file = file.upper() # paths are not case-sensitive on Windows if sys.platform.startswith('win'): # a POSIX-specific check
file = file.upper() # paths are not case-sensitive on Windows
for extension in available_extensions:
if file == '%s%s' % (name, extension): for extension in available_extensions:
yield path if file == '%s%s' % (name, extension):
yield path
def is_running_as_root() -> bool: def is_running_as_root() -> bool:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment