public static void HeartBeat(string apiKey, string file, bool write = false)
{
if (!PythonManager.IsPythonInstalled())
{
return;
}
string arguments = "--key " + apiKey +
" --file " + "\"" + file + "\"" +
" --plugin " + WakaTimeConstants.PLUGIN_NAME +
" --project " + Main.GetProjectName() +
" --verbose";
if (Main.IsDebug)
{
UnityEngine.Debug.Log("Sending file: " + PythonManager.GetPythonPath() + " " + GetClientPath() +
" " + arguments);
}
Process p = new Process {
StartInfo =
{
FileName = PythonManager.GetPythonPath(),
Arguments = "\"" + GetClientPath() + "\" " + arguments,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = Application.dataPath,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
}
};
p.Start();
if (Main.IsDebug)
{
var output = p.StandardOutput.ReadToEnd();
if (output.Length > 0)
{
UnityEngine.Debug.Log("Wakatime Output: " + output);
}
var errors = p.StandardError.ReadToEnd();
if (errors.Length > 0)
{
UnityEngine.Debug.LogError("Wakatime Error: " + errors);
}
}
p.Close();
}