mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #324 from taooceros/fixPythonPlugin
Fix python plugin Json Desterilize issue
This commit is contained in:
commit
ababcb480e
4 changed files with 36 additions and 37 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
|
|
||||||
namespace Flow.Launcher.Core.Plugin
|
namespace Flow.Launcher.Core.Plugin
|
||||||
|
|
@ -42,6 +43,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
|
|
||||||
public class JsonRPCQueryResponseModel : JsonRPCResponseModel
|
public class JsonRPCQueryResponseModel : JsonRPCResponseModel
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("result")]
|
||||||
public new List<JsonRPCResult> Result { get; set; }
|
public new List<JsonRPCResult> Result { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,47 +147,42 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var process = Process.Start(startInfo))
|
using var process = Process.Start(startInfo);
|
||||||
|
if (process == null)
|
||||||
{
|
{
|
||||||
if (process != null)
|
Log.Error("|JsonRPCPlugin.Execute|Can't start new process");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var standardOutput = process.StandardOutput;
|
||||||
|
var result = standardOutput.ReadToEnd();
|
||||||
|
if (string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
using (var standardError = process.StandardError)
|
||||||
{
|
{
|
||||||
using (var standardOutput = process.StandardOutput)
|
var error = standardError.ReadToEnd();
|
||||||
|
if (!string.IsNullOrEmpty(error))
|
||||||
{
|
{
|
||||||
var result = standardOutput.ReadToEnd();
|
Log.Error($"|JsonRPCPlugin.Execute|{error}");
|
||||||
if (string.IsNullOrEmpty(result))
|
return string.Empty;
|
||||||
{
|
}
|
||||||
using (var standardError = process.StandardError)
|
else
|
||||||
{
|
{
|
||||||
var error = standardError.ReadToEnd();
|
Log.Error("|JsonRPCPlugin.Execute|Empty standard output and standard error.");
|
||||||
if (!string.IsNullOrEmpty(error))
|
return string.Empty;
|
||||||
{
|
|
||||||
Log.Error($"|JsonRPCPlugin.Execute|{error}");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Error("|JsonRPCPlugin.Execute|Empty standard output and standard error.");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (result.StartsWith("DEBUG:"))
|
|
||||||
{
|
|
||||||
MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Error("|JsonRPCPlugin.Execute|Can't start new process");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (result.StartsWith("DEBUG:"))
|
||||||
|
{
|
||||||
|
MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,8 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
token.ThrowIfCancellationRequested();
|
token.ThrowIfCancellationRequested();
|
||||||
|
if (results == null)
|
||||||
|
return results;
|
||||||
UpdatePluginMetadata(results, metadata, query);
|
UpdatePluginMetadata(results, metadata, query);
|
||||||
|
|
||||||
metadata.QueryCount += 1;
|
metadata.QueryCount += 1;
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match.IsSearchPrecisionScoreMet()) return false;
|
if (!match.IsSearchPrecisionScoreMet()) return false;
|
||||||
|
|
||||||
r.Score = match.Score;
|
r.Score = match.Score;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -512,7 +512,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
await Task.Yield();
|
await Task.Yield();
|
||||||
|
|
||||||
var results = await PluginManager.QueryForPlugin(plugin, query, currentCancellationToken);
|
var results = await PluginManager.QueryForPlugin(plugin, query, currentCancellationToken);
|
||||||
if (!currentCancellationToken.IsCancellationRequested)
|
if (!currentCancellationToken.IsCancellationRequested && results != null)
|
||||||
_resultsUpdateQueue.Post(new ResultsForUpdate(results, plugin.Metadata, query,
|
_resultsUpdateQueue.Post(new ResultsForUpdate(results, plugin.Metadata, query,
|
||||||
currentCancellationToken));
|
currentCancellationToken));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue