|
|
|
|
|
|
using System.Diagnostics; |
|
|
|
using System.Threading; |
|
|
|
using System.IO; |
|
|
|
using UnityEditor; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Runs pyrception instance in default browser
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
command = $"cd {path}/DataInsightsEnv/Scripts; activate; pyrception-utils preview --data=\"{PlayerPrefs.GetString(SimulationState.latestOutputDirectoryKey)}/..\""; |
|
|
|
#endif
|
|
|
|
int ExitCode = ExecuteCMD(command, false, true); |
|
|
|
if (ExitCode != 0) return; |
|
|
|
if (ExitCode != 0) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Installing virtualenv...", 0 / steps); |
|
|
|
int ExitCode = 0; |
|
|
|
ExitCode = ExecuteCMD("pip install virtualenv"); |
|
|
|
if (ExitCode != 0) return; |
|
|
|
if (ExitCode != 0) |
|
|
|
return; |
|
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Setting up virtualenv instance...", 1f / steps); |
|
|
|
|
|
|
|
|
|
|
ExitCode = ExecuteCMD($"virtualenv \"{path}/DataInsightsEnv\""); |
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) return; |
|
|
|
if (ExitCode != 0) |
|
|
|
return; |
|
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Getting pyrception files...", 2f / steps); |
|
|
|
|
|
|
|
|
|
|
ExitCode = ExecuteCMD($"\\cp -r \"{pyrceptionPath}\" \"{path}/DataInsightsEnv/pyrception-util\""); |
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) return; |
|
|
|
if (ExitCode != 0) |
|
|
|
return; |
|
|
|
ExitCode = ExecuteCMD($"\"{path}\\DataInsightsEnv\\Scripts\\activate\" && cd {path} && cd .\\DataInsightsEnv\\pyrception-util\\ && pip --no-cache-dir install -e . && deactivate"); |
|
|
|
ExitCode = ExecuteCMD($"\"{path}\\DataInsightsEnv\\Scripts\\activate\" && cd \"{path}\\DataInsightsEnv\\pyrception-util\" && pip --no-cache-dir install -e . && deactivate"); |
|
|
|
if (ExitCode != 0) return; |
|
|
|
if (ExitCode != 0) |
|
|
|
return; |
|
|
|
|
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
} |
|
|
|
|
|
|
/// <param name="waitForExit">Should it wait for exit before returning to the editor (i.e. is it not async?)</param>
|
|
|
|
/// <param name="displayWindow">Should the command window be displayed</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private static int ExecuteCMD(string command, bool waitForExit = true, bool displayWindow = false) { |
|
|
|
private static int ExecuteCMD(string command, bool waitForExit = true, bool displayWindow = false) |
|
|
|
{ |
|
|
|
argument = $"/c {command}"; |
|
|
|
argument = $"/c \"{command}\""; |
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
shell = "/bin/bash"; |
|
|
|
argument = $"-c \"{command}\""; |
|
|
|
|
|
|
info.UseShellExecute = !waitForExit; |
|
|
|
|
|
|
|
Process cmd = Process.Start(info); |
|
|
|
if (!waitForExit) return 0; |
|
|
|
if (!waitForExit) |
|
|
|
return 0; |
|
|
|
|
|
|
|
cmd.WaitForExit(); |
|
|
|
int ExitCode = 0; |
|
|
|