Check permission and handle PermissionError exception

Signed-off-by: Mike Li <Tianxinmike.Li@amd.com>
Change-Id: If7cb8464d0b761e4be45c85eb7147ceed609da61
Этот коммит содержится в:
Mike Li
2022-08-17 11:44:09 -04:00
родитель d8f236cd81
Коммит 3a4d533a1e
+7 -2
Просмотреть файл
@@ -195,10 +195,15 @@ def readFromKFD():
node_path = os.path.join(topology_dir, node)
if os.path.isdir(node_path):
prop_path = node_path + '/properties'
if os.path.isfile(prop_path):
if os.path.isfile(prop_path) and os.access(prop_path, os.R_OK):
target_search_term = re.compile("gfx_target_version.+")
with open(prop_path) as f:
line = f.readline()
try:
line = f.readline()
except PermissionError:
# We may have a subsystem (e.g. scheduler) limiting device visibility which
# could cause a permission error.
line = ''
while line != '' :
search_result = target_search_term.search(line)
if search_result is not None: