Skip to content

Commit 17950d6

Browse files
committed
Catch OSError in core.check_file_and_perms()
1 parent 9389a5d commit 17950d6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

osgtest/library/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,12 @@ def check_file_and_perms(file_path, owner_name, permissions):
654654
"""Return True if the file at 'file_path' exists, is owned by
655655
'owner_name', is a file, and has the given permissions; False otherwise
656656
"""
657-
file_stat = os.stat(file_path)
658-
return (check_file_ownership(file_path, owner_name) and
659-
file_stat.st_mode & 0o7777 == permissions)
657+
try:
658+
file_stat = os.stat(file_path)
659+
return (check_file_ownership(file_path, owner_name) and
660+
file_stat.st_mode & 0o7777 == permissions)
661+
except OSError: # file does not exist
662+
return False
660663

661664
def parse_env_output(output):
662665
"""

0 commit comments

Comments
 (0)