Fix FileNotFoundException crash in find_python_executable_for_version… (#192)

* Fix FileNotFoundException crash in find_python_executable_for_version (#164)

* Add a Windows check for error 9009 when searching for Python

---------

Co-authored-by: 12037964+ae-ae@users.noreply.github.com 12037964+ae-ae@users.noreply.github.com <ae-ae>
This commit is contained in:
ae-ae 2024-03-06 10:17:31 +03:00 committed by GitHub
parent a2758250b2
commit 8b2970350c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3365,8 +3365,15 @@ class Worker(ServiceCommandSection):
stderr=subprocess.STDOUT stderr=subprocess.STDOUT
) )
except subprocess.CalledProcessError as ex: except subprocess.CalledProcessError as ex:
# Windows returns 9009 code and suggests to install Python from Windows Store
if is_windows_platform() and ex.returncode == 9009:
self.log.debug("version not found: {}".format(ex))
else:
self.log.warning("error getting %s version: %s", executable, ex) self.log.warning("error getting %s version: %s", executable, ex)
continue continue
except FileNotFoundError as ex:
self.log.debug("version not found: {}".format(ex))
continue
if not default_python: if not default_python:
match = re.search(r"Python ({}(?:\.\d+)*)".format(r"\d+"), output) match = re.search(r"Python ({}(?:\.\d+)*)".format(r"\d+"), output)