Skip to content
Snippets Groups Projects
Commit f0490818 authored by Lab1's avatar Lab1
Browse files

make VA Server launcher check whether python/py exists and give an error otherwise

parent b2ca2281
Branches
No related tags found
No related merge requests found
...@@ -128,11 +128,38 @@ bool FVAServerLauncher::StartVAServerLauncher() ...@@ -128,11 +128,38 @@ bool FVAServerLauncher::StartVAServerLauncher()
FString LauncherScript = TEXT("VirtualAcousticsStarterServer.py"); FString LauncherScript = TEXT("VirtualAcousticsStarterServer.py");
if (FPaths::FileExists(FPaths::Combine(LauncherScriptDir, LauncherScript))) if (FPaths::FileExists(FPaths::Combine(LauncherScriptDir, LauncherScript)))
{ {
FString command = "cd/d "+ LauncherScriptDir+" & start python " + LauncherScript; FString CMDCommand = "cd/d " + LauncherScriptDir + " & ";
system(TCHAR_TO_ANSI(*command));
//check whether py or python exist
auto DoesCommandExist = [&](FString Command)
{
//this checks whether a given command returns a result
FString TmpCmdResultFile = "tmpPyVersion.txt";
TmpCmdResultFile = FPaths::Combine(LauncherScriptDir, TmpCmdResultFile);
Command = Command + " >> " + TmpCmdResultFile;
system(TCHAR_TO_ANSI(*Command));
FString Result;
FFileHelper::LoadFileToString(Result, *TmpCmdResultFile);
IFileManager::Get().Delete(*TmpCmdResultFile);
return !Result.IsEmpty();
};
bool bPyExists = DoesCommandExist("py --version");
bool bPythonExists = DoesCommandExist("python --version");
if(bPythonExists || bPyExists)
{
FString Command = CMDCommand + "start " + (bPythonExists?"python":"py") + " " + LauncherScript;
system(TCHAR_TO_ANSI(*Command));
return true; return true;
} }
else else
{
FVAUtils::OpenMessageBox("VA Launcher cannot be started since neither \"py\" nor \"python\" can be found. If it is installed add it to PATH (and restart Visual Studio)", true);
return false;
}
}
else
{ {
FVAUtils::LogStuff("[FVAServerLauncher::StartVAServerLauncher] Unable to automatically start the launcher script, looked for "+LauncherScript+" at "+LauncherScriptDir+". If you want to use this convenience function change the VALauncher Path in the Engine/Virtual Acoustics(VA) section of the project settings. However, nothing bad will happen without."); FVAUtils::LogStuff("[FVAServerLauncher::StartVAServerLauncher] Unable to automatically start the launcher script, looked for "+LauncherScript+" at "+LauncherScriptDir+". If you want to use this convenience function change the VALauncher Path in the Engine/Virtual Acoustics(VA) section of the project settings. However, nothing bad will happen without.");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment