浏览代码

Fix installation wait for exit period

/pyrception-integration
leopoldo-zugasti 3 年前
当前提交
e7ce3e8d
共有 2 个文件被更改,包括 20 次插入12 次删除
  1. 2
      com.unity.perception/Editor/Visualizer/PythonForUnityInstaller.cs
  2. 30
      com.unity.perception/Editor/Visualizer/VisualizerInstaller.cs

2
com.unity.perception/Editor/Visualizer/PythonForUnityInstaller.cs


if (!checkIfPackageInstalled())
{
AddRequest request = Client.Add("com.unity.scripting.python@4.0.0-exp.5");
EditorUtility.DisplayProgressBar("Setting up the Visualizer", "Installing the Visualizer...", 0.2f);
while (!request.IsCompleted)
{

30
com.unity.perception/Editor/Visualizer/VisualizerInstaller.cs


//==============================INSTALL VISUALIZER IN PYTHON FOR UNITY======================================
EditorUtility.DisplayProgressBar("Setting up the Visualizer", "Installing the Visualizer...", 2.5f / steps);
EditorUtility.DisplayProgressBar("Setting up the Visualizer", "Installing Visualizer (This may take a few minutes - this only happens once)", 2.5f / steps);
ExecuteCMD($"\"{packagesPath}\"\\pip3.bat install --upgrade --no-warn-script-location unity-cv-datasetvisualizer", ref ExitCode, ref output, waitForExit: 0);
ExecuteCMD($"\"{packagesPath}\"\\pip3.bat install --upgrade --no-warn-script-location unity-cv-datasetvisualizer", ref ExitCode, ref output, waitForExit: -1);
ExecuteCMD($"cd \'{packagesPath}\'; ./python3.7 -m pip install --upgrade unity-cv-datasetvisualizer", ref ExitCode, ref output, waitForExit: 0);
ExecuteCMD($"cd \'{packagesPath}\'; ./python3.7 -m pip install --upgrade unity-cv-datasetvisualizer", ref ExitCode, ref output, waitForExit: -1);
#endif
if (ExitCode != 0) {
EditorUtility.ClearProgressBar();

/// <returns></returns>
private static int ExecuteCMD(string command, ref int ExitCode, ref string output, int waitForExit = 0, bool displayWindow = false, bool getOutput = false)
{
UnityEngine.Debug.Log(command);
string shell = "";
string argument = "";

info.CreateNoWindow = !displayWindow;
info.UseShellExecute = false;
info.RedirectStandardOutput = getOutput;
info.RedirectStandardError = waitForExit != 0;
info.RedirectStandardError = waitForExit > 0;
Process cmd = Process.Start(info);

}
cmd.WaitForExit(waitForExit);
if(waitForExit == -1)
{
cmd.WaitForExit();
}
else if(waitForExit > 0)
{
cmd.WaitForExit(waitForExit);
}
ExitCode = cmd.ExitCode;
if (ExitCode != 0)
{
UnityEngine.Debug.LogError($"Error - {ExitCode} - Failed to execute: {command} - {cmd.StandardError.ReadToEnd()}");
if (cmd.HasExited){
ExitCode = cmd.ExitCode;
if (ExitCode != 0)
{
UnityEngine.Debug.LogError($"Error - {ExitCode} - Failed to execute: {command} - {cmd.StandardError.ReadToEnd()}");
}
}
cmd.Close();

正在加载...
取消
保存