mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 07:59:47 +00:00
Included expressive Error Messages if pandoc is not installed or the minimum version requirement is not met
This commit is contained in:
parent
266fdb9b96
commit
e578796dbf
@ -6,7 +6,6 @@ namespace AIStudio.Tools;
|
|||||||
|
|
||||||
public static partial class Pandoc
|
public static partial class Pandoc
|
||||||
{
|
{
|
||||||
// Minimale erforderliche Version von Pandoc
|
|
||||||
private static readonly Version MINIMUM_REQUIRED_VERSION = new Version(3, 6, 0);
|
private static readonly Version MINIMUM_REQUIRED_VERSION = new Version(3, 6, 0);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -27,37 +26,49 @@ public static partial class Pandoc
|
|||||||
};
|
};
|
||||||
using var process = Process.Start(startInfo);
|
using var process = Process.Start(startInfo);
|
||||||
if (process == null)
|
if (process == null)
|
||||||
|
{
|
||||||
|
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.AppsOutage, $"Pandoc is not installed."));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var output = await process.StandardOutput.ReadToEndAsync();
|
var output = await process.StandardOutput.ReadToEndAsync();
|
||||||
await process.WaitForExitAsync();
|
await process.WaitForExitAsync();
|
||||||
if (process.ExitCode != 0)
|
if (process.ExitCode != 0)
|
||||||
|
{
|
||||||
|
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.AppsOutage, $"Pandoc is not installed."));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var versionMatch = PandocRegex().Match(output);
|
var versionMatch = PandocRegex().Match(output);
|
||||||
if (!versionMatch.Success) return false;
|
if (!versionMatch.Success)
|
||||||
|
{
|
||||||
|
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.AppsOutage, $"Pandoc is not installed."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var versions = versionMatch.Groups[1].Value.Split('.');
|
var versions = versionMatch.Groups[1].Value.Split('.');
|
||||||
var major = int.Parse(versions[0]);
|
var major = int.Parse(versions[0]);
|
||||||
var minor = int.Parse(versions[1]);
|
var minor = int.Parse(versions[1]);
|
||||||
var patch = int.Parse(versions[2]);
|
var patch = int.Parse(versions[2]);
|
||||||
var installedVersion = new Version(major, minor, patch);
|
var installedVersion = new Version(major, minor, patch);
|
||||||
|
|
||||||
return installedVersion >= MINIMUM_REQUIRED_VERSION;
|
if (installedVersion >= MINIMUM_REQUIRED_VERSION)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.AppsOutage, $"Pandoc {installedVersion.ToString()} is installed, but it doesn't match the required version ({MINIMUM_REQUIRED_VERSION.ToString()}).\n"));
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
await MessageBus.INSTANCE.SendError(new (@Icons.Material.Filled.AppsOutage, "An unknown error occured while checking for Pandoc."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt den Namen der Pandoc-Executable basierend auf dem Betriebssystem zurück.
|
/// Returns the name of the pandoc executable based on the running operating system
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string GetPandocExecutableName()
|
private static string GetPandocExecutableName() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "pandoc.exe" : "pandoc";
|
||||||
{
|
|
||||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "pandoc.exe" : "pandoc";
|
|
||||||
}
|
|
||||||
|
|
||||||
[GeneratedRegex(@"pandoc(?:\.exe)?\s*([0-9]+\.[0-9]+\.[0-9]+)")]
|
[GeneratedRegex(@"pandoc(?:\.exe)?\s*([0-9]+\.[0-9]+\.[0-9]+)")]
|
||||||
private static partial Regex PandocRegex();
|
private static partial Regex PandocRegex();
|
||||||
|
Loading…
Reference in New Issue
Block a user