mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
tools: add system check to verify Python versions and Windows Defender status
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
{ Copyright 2019-2020 Espressif Systems (Shanghai) CO LTD
|
||||
SPDX-License-Identifier: Apache-2.0 }
|
||||
|
||||
{ ------------------------------ Find installed Python interpreters in Windows Registry (see PEP 514) ------------------------------ }
|
||||
@@ -19,7 +19,8 @@ end;
|
||||
function GetPythonVersionInfoFromKey(RootKey: Integer; SubKeyName, CompanyName, TagName: String;
|
||||
var Version: String;
|
||||
var DisplayName: String;
|
||||
var ExecutablePath: String): Boolean;
|
||||
var ExecutablePath: String;
|
||||
var BaseDir: String): Boolean;
|
||||
var
|
||||
TagKey, InstallPathKey, DefaultPath: String;
|
||||
begin
|
||||
@@ -39,6 +40,8 @@ begin
|
||||
ExecutablePath := DefaultPath + '\python.exe';
|
||||
end;
|
||||
|
||||
BaseDir := DefaultPath;
|
||||
|
||||
if not RegQueryStringValue(RootKey, TagKey, 'SysVersion', Version) then
|
||||
begin
|
||||
if CompanyName = 'PythonCore' then
|
||||
@@ -59,55 +62,3 @@ begin
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure FindPythonVersionsFromKey(RootKey: Integer; SubKeyName: String);
|
||||
var
|
||||
CompanyNames: TArrayOfString;
|
||||
CompanyName, CompanySubKey, TagName, TagSubKey: String;
|
||||
ExecutablePath, DisplayName, Version: String;
|
||||
TagNames: TArrayOfString;
|
||||
CompanyId, TagId: Integer;
|
||||
begin
|
||||
if not RegGetSubkeyNames(RootKey, SubKeyName, CompanyNames) then
|
||||
begin
|
||||
Log('Nothing found in ' + IntToStr(RootKey) + '\' + SubKeyName);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
for CompanyId := 0 to GetArrayLength(CompanyNames) - 1 do
|
||||
begin
|
||||
CompanyName := CompanyNames[CompanyId];
|
||||
|
||||
if CompanyName = 'PyLauncher' then
|
||||
continue;
|
||||
|
||||
CompanySubKey := SubKeyName + '\' + CompanyName;
|
||||
Log('In ' + IntToStr(RootKey) + '\' + CompanySubKey);
|
||||
|
||||
if not RegGetSubkeyNames(RootKey, CompanySubKey, TagNames) then
|
||||
continue;
|
||||
|
||||
for TagId := 0 to GetArrayLength(TagNames) - 1 do
|
||||
begin
|
||||
TagName := TagNames[TagId];
|
||||
TagSubKey := CompanySubKey + '\' + TagName;
|
||||
Log('In ' + IntToStr(RootKey) + '\' + TagSubKey);
|
||||
|
||||
if not GetPythonVersionInfoFromKey(RootKey, SubKeyName, CompanyName, TagName, Version, DisplayName, ExecutablePath) then
|
||||
continue;
|
||||
|
||||
PythonVersionAdd(Version, DisplayName, ExecutablePath);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure FindInstalledPythonVersions();
|
||||
begin
|
||||
InstalledPythonVersions := TStringList.Create();
|
||||
InstalledPythonDisplayNames := TStringList.Create();
|
||||
InstalledPythonExecutables := TStringList.Create();
|
||||
|
||||
FindPythonVersionsFromKey(HKEY_CURRENT_USER, 'Software\Python');
|
||||
FindPythonVersionsFromKey(HKEY_LOCAL_MACHINE, 'Software\Python');
|
||||
FindPythonVersionsFromKey(HKEY_LOCAL_MACHINE, 'Software\Wow6432Node\Python');
|
||||
end;
|
||||
|
Reference in New Issue
Block a user