mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix crash issue when user didn't install python.
This commit is contained in:
parent
f308496ef9
commit
db8371d3af
1 changed files with 16 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using Python.Runtime;
|
||||
using Wox.Plugin;
|
||||
using Wox.Helper;
|
||||
|
||||
namespace Wox.PluginLoader
|
||||
{
|
||||
|
|
@ -11,6 +12,8 @@ namespace Wox.PluginLoader
|
|||
{
|
||||
public override List<PluginPair> LoadPlugin()
|
||||
{
|
||||
if (!CheckPythonEnvironmentInstalled()) return new List<PluginPair>();
|
||||
|
||||
List<PluginPair> plugins = new List<PluginPair>();
|
||||
List<PluginMetadata> metadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == AllowedLanguage.Python.ToUpper()).ToList();
|
||||
foreach (PluginMetadata metadata in metadatas)
|
||||
|
|
@ -26,5 +29,18 @@ namespace Wox.PluginLoader
|
|||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private bool CheckPythonEnvironmentInstalled() {
|
||||
try
|
||||
{
|
||||
PythonEngine.Initialize();
|
||||
PythonEngine.Shutdown();
|
||||
}
|
||||
catch {
|
||||
Log.Error("Could't find python environment, all python plugins disabled.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue