mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Add portable python environment
This commit is contained in:
@@ -10,14 +10,14 @@ using Wox.RPC;
|
||||
|
||||
namespace Wox.PluginLoader
|
||||
{
|
||||
public abstract class BasePluginWrapper : IPlugin
|
||||
public abstract class BasePlugin : IPlugin
|
||||
{
|
||||
protected PluginInitContext context;
|
||||
|
||||
public abstract List<string> GetAllowedLanguages();
|
||||
|
||||
protected abstract string ExecuteQuery(Query query);
|
||||
protected abstract string ExecuteAction(string rpcRequest);
|
||||
protected abstract string ExecuteAction(JsonRPCRequestModel rpcRequest);
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
@@ -29,13 +29,13 @@ namespace Wox.PluginLoader
|
||||
List<Result> results = new List<Result>();
|
||||
|
||||
JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject<JsonRPCQueryResponseModel>(output);
|
||||
foreach (JsonRPCResult result in queryResponseModel.QueryResults)
|
||||
foreach (JsonRPCResult result in queryResponseModel.Result)
|
||||
{
|
||||
if (result.JSONRPCActionModel != null)
|
||||
if (result.JsonRPCAction != null)
|
||||
{
|
||||
result.Action = (c) =>
|
||||
{
|
||||
ExecuteAction(result.JSONRPCAction);
|
||||
string actionResponse = ExecuteAction(result.JsonRPCAction);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Wox.RPC;
|
||||
|
||||
namespace Wox.PluginLoader
|
||||
{
|
||||
public class BasePluginLoader<T> : IPluginLoader where T : BasePluginWrapper, new()
|
||||
public class BasePluginLoader<T> : IPluginLoader where T : BasePlugin, new()
|
||||
{
|
||||
public virtual List<PluginPair> LoadPlugin(List<PluginMetadata> pluginMetadatas)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ using Wox.Plugin.SystemPlugins;
|
||||
|
||||
namespace Wox.PluginLoader {
|
||||
|
||||
public class CSharpPluginConfigLoader : IPluginLoader
|
||||
public class CSharpPluginLoader : IPluginLoader
|
||||
{
|
||||
public List<PluginPair> LoadPlugin(List<PluginMetadata> pluginMetadatas)
|
||||
{
|
||||
@@ -16,8 +16,8 @@ namespace Wox.PluginLoader
|
||||
plugins.Clear();
|
||||
List<PluginMetadata> pluginMetadatas = PluginConfigLoader.ParsePluginsConfig();
|
||||
|
||||
plugins.AddRange(new CSharpPluginConfigLoader().LoadPlugin(pluginMetadatas));
|
||||
plugins.AddRange(new BasePluginLoader<PythonPluginWrapper>().LoadPlugin(pluginMetadatas));
|
||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin(pluginMetadatas));
|
||||
plugins.AddRange(new BasePluginLoader<PythonPlugin>().LoadPlugin(pluginMetadatas));
|
||||
|
||||
Forker forker = new Forker();
|
||||
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
|
||||
|
||||
@@ -5,7 +5,7 @@ using Wox.RPC;
|
||||
|
||||
namespace Wox.PluginLoader
|
||||
{
|
||||
public class PythonPluginWrapper : BasePluginWrapper
|
||||
public class PythonPlugin : BasePlugin
|
||||
{
|
||||
private static string woxDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace Wox.PluginLoader
|
||||
|
||||
protected override string ExecuteQuery(Query query)
|
||||
{
|
||||
string fileName = Path.Combine(woxDirectory, "PYTHONTHOME\\Scripts\\python.exe");
|
||||
string fileName = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe");
|
||||
string parameters = string.Format("{0} \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath,
|
||||
JsonRPC.Send("query", query.GetAllRemainingParameter()));
|
||||
return Execute(fileName, parameters);
|
||||
}
|
||||
|
||||
protected override string ExecuteAction(string rpcRequest)
|
||||
protected override string ExecuteAction(JsonRPCRequestModel rpcRequest)
|
||||
{
|
||||
string fileName = Path.Combine(woxDirectory, "PYTHONTHOME\\Scripts\\python.exe");
|
||||
string fileName = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe");
|
||||
string parameters = string.Format("{0} \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath,
|
||||
rpcRequest);
|
||||
rpcRequest.ToString());
|
||||
return Execute(fileName, parameters);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user