コード例 #1
0
ファイル: Python.cs プロジェクト: theshrkclan123/flowframes
        static string GetSysPythonOutput()
        {
            Process py = OSUtils.NewProcess(true);

            py.StartInfo.Arguments = "/C python -V";
            Logger.Log("[DepCheck] CMD: " + py.StartInfo.Arguments, true);
            py.Start();
            py.WaitForExit();
            string output = py.StandardOutput.ReadToEnd();
            string err    = py.StandardError.ReadToEnd();

            return(output + "\n" + err);
        }
コード例 #2
0
ファイル: Python.cs プロジェクト: theshrkclan123/flowframes
        public static async Task CheckCompression()
        {
            if (HasEmbeddedPyFolder() && (Config.Get("compressedPyVersion") != Updater.GetInstalledVer().ToString()))
            {
                Program.mainForm.SetWorking(true, false);
                Stopwatch sw = new Stopwatch();
                sw.Restart();
                try
                {
                    bool shownPatienceMsg = false;
                    Logger.Log("Compressing python runtime. This only needs to be done once.");
                    compactOutput = "";
                    Process compact = OSUtils.NewProcess(true);
                    compact.StartInfo.Arguments = $"/C compact /C /S:{GetPyFolder().Wrap()} /EXE:LZX";
                    compact.OutputDataReceived += new DataReceivedEventHandler(CompactOutputHandler);
                    compact.ErrorDataReceived  += new DataReceivedEventHandler(CompactOutputHandler);
                    compact.Start();
                    compact.BeginOutputReadLine();
                    compact.BeginErrorReadLine();
                    while (!compact.HasExited)
                    {
                        await Task.Delay(500);

                        if (sw.ElapsedMilliseconds > 10000)
                        {
                            Logger.Log($"This can take up to a few minutes... (Elapsed: {FormatUtils.Time(sw.Elapsed)})", false, shownPatienceMsg);
                            shownPatienceMsg = true;
                            await Task.Delay(500);
                        }
                    }
                    Config.Set("compressedPyVersion", Updater.GetInstalledVer().ToString());
                    Logger.Log("Done compressing python runtime.");
                    Logger.WriteToFile(compactOutput, true, "compact");
                }
                catch { }
                Program.mainForm.SetWorking(false);
            }
        }
コード例 #3
0
ファイル: Python.cs プロジェクト: theshrkclan123/flowframes
 static string GetPytorchVer()
 {
     try
     {
         Process py = OSUtils.NewProcess(true);
         py.StartInfo.Arguments = "\"/C\" " + GetPyCmd() + " -c \"import torch; print(torch.__version__)\"";
         Logger.Log("[DepCheck] CMD: " + py.StartInfo.Arguments);
         py.Start();
         py.WaitForExit();
         string output = py.StandardOutput.ReadToEnd();
         string err    = py.StandardError.ReadToEnd();
         if (!string.IsNullOrWhiteSpace(err))
         {
             output += "\n" + err;
         }
         Logger.Log("[DepCheck] Pytorch Check Output: " + output.Trim());
         return(output);
     }
     catch
     {
         return("");
     }
 }