From 92d6196f674f12ae4612c5e86e97849b86179402 Mon Sep 17 00:00:00 2001 From: lixintao Date: Fri, 12 Jul 2024 15:05:17 +0800 Subject: [PATCH] Add a determination of whether the path exists in os.stat Signed-off-by: lixintao --- avocado/utils/path.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/avocado/utils/path.py b/avocado/utils/path.py index 5c52c66cc5..2a7d55ccb5 100644 --- a/avocado/utils/path.py +++ b/avocado/utils/path.py @@ -133,8 +133,9 @@ def get_first_line(self): return first_line def has_exec_permission(self): - mode = os.stat(self.path)[stat.ST_MODE] - return mode & stat.S_IXUSR + if os.path.exists(self.path): + mode = os.stat(self.path)[stat.ST_MODE] + return mode & stat.S_IXUSR def is_empty(self): if os.path.exists(self.path):