Python.cs: DisablePython check in CheckCompression + some refactoring

This commit is contained in:
N00MKRAD
2024-08-11 20:47:36 +02:00
parent 8df4e31b72
commit 6c406a4846

View File

@@ -2,12 +2,9 @@
using Flowframes.IO; using Flowframes.IO;
using Flowframes.MiscUtils; using Flowframes.MiscUtils;
using Flowframes.Ui; using Flowframes.Ui;
using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace Flowframes.Os namespace Flowframes.Os
{ {
@@ -20,8 +17,9 @@ namespace Flowframes.Os
public static async Task CheckCompression () public static async Task CheckCompression ()
{ {
if(HasEmbeddedPyFolder() && (Config.Get(Config.Key.compressedPyVersion) != Updater.GetInstalledVer().ToString())) if (Implementations.DisablePython || !HasEmbeddedPyFolder() || (Config.Get(Config.Key.compressedPyVersion) == Updater.GetInstalledVer().ToString()))
{ return;
Program.mainForm.SetWorking(true, false); Program.mainForm.SetWorking(true, false);
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Restart(); sw.Restart();
@@ -41,14 +39,15 @@ namespace Flowframes.Os
while (!compact.HasExited) while (!compact.HasExited)
{ {
await Task.Delay(500); await Task.Delay(500);
if(sw.ElapsedMilliseconds > 10000)
if (sw.ElapsedMilliseconds > 10000)
{ {
Logger.Log($"This can take up to a few minutes, but only needs to be done once. (Elapsed: {FormatUtils.Time(sw.Elapsed)})", false, shownPatienceMsg); Logger.Log($"This can take up to a few minutes, but only needs to be done once. (Elapsed: {FormatUtils.Time(sw.Elapsed)})", false, shownPatienceMsg);
shownPatienceMsg = true; shownPatienceMsg = true;
await Task.Delay(500); await Task.Delay(500);
} }
} }
Config.Set("compressedPyVersion", Updater.GetInstalledVer().ToString()); Config.Set("compressedPyVersion", Updater.GetInstalledVer().ToString());
Logger.Log("Done compressing python runtime."); Logger.Log("Done compressing python runtime.");
Logger.WriteToFile(compactOutput, true, "compact"); Logger.WriteToFile(compactOutput, true, "compact");
@@ -56,14 +55,13 @@ namespace Flowframes.Os
catch { } catch { }
Program.mainForm.SetWorking(false); Program.mainForm.SetWorking(false);
} }
}
static void CompactOutputHandler (object sendingProcess, DataReceivedEventArgs outLine) static void CompactOutputHandler (object sendingProcess, DataReceivedEventArgs outLine)
{ {
if (outLine == null || outLine.Data == null) if (outLine == null || outLine.Data == null)
return; return;
string line = outLine.Data;
compactOutput = compactOutput + line + "\n"; compactOutput = $"{compactOutput}{outLine.Data}\n";
} }
public static string GetPyCmd (bool unbufferedStdOut = true, bool quiet = false) public static string GetPyCmd (bool unbufferedStdOut = true, bool quiet = false)