浏览代码

Remove command window popping up and improve executing commands

/pyrception-integration
leopoldo-zugasti 4 年前
当前提交
4b2e1502
共有 1 个文件被更改,包括 32 次插入19 次删除
  1. 51
      com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs

51
com.unity.perception/Editor/Pyrception/PyrceptionInstaller.cs


{
string path = Application.dataPath.Replace("/Assets", "").Replace("/", "\\");
string pyrceptionPath = Path.GetFullPath("Packages/com.unity.perception/Editor/Pyrception/pyrception-utils");
UnityEngine.Debug.Log(pyrceptionPath);
string command =
$"pip install virtualenv && " +
$"cd {path} && " +
$"virtualenv DataInsightsEnv && " +
$"XCOPY /E/I/Y {pyrceptionPath} .\\DataInsightsEnv\\pyrception-util && " +
$".\\DataInsightsEnv\\Scripts\\activate && " +
$"cd .\\DataInsightsEnv\\pyrception-util && " +
$"pip --no-cache-dir install -e .";
int ExitCode = 0;
ExitCode = ExecuteCMD("pip install virtualenv");
if (ExitCode != 0) return;
ExitCode = ExecuteCMD($"virtualenv \"{path}\\DataInsightsEnv\"");
if (ExitCode != 0) return;
ExitCode = ExecuteCMD($"XCOPY /E/I/Y \"{pyrceptionPath}\" \"{path}\\DataInsightsEnv\\pyrception-util\"");
if (ExitCode != 0) return;
ExitCode = ExecuteCMD($"cd \"{path}\\DataInsightsEnv\\pyrception-util\"");
if (ExitCode != 0) return;
ExitCode = ExecuteCMD($"\"{path}\\DataInsightsEnv\\Scripts\\activate\" && cd {path} && cd .\\DataInsightsEnv\\pyrception-util\\ && pip --no-cache-dir install -e . && deactivate");
if (ExitCode != 0) return;
}
private static int ExecuteCMD(string command) {
info.CreateNoWindow = false;
info.UseShellExecute = true;
info.CreateNoWindow = true;
info.UseShellExecute = false;
int ExitCode = cmd.ExitCode;
if(ExitCode == 0)
int ExitCode = 0;
ExitCode = cmd.ExitCode;
if (ExitCode != 0)
UnityEngine.Debug.Log("Completed setup for Dataset Insights");
UnityEngine.Debug.LogError($"Error - {ExitCode} - Failed to execute: {command}");
else
{
UnityEngine.Debug.LogError("Dataset Insights setup failed");
}
return cmd.ExitCode;
}
private static void RevertChanges() {
return;
}
}
正在加载...
取消
保存