Add portable python environment

This commit is contained in:
qianlifeng
2014-07-09 18:15:23 +08:00
parent 3efe3d63ce
commit 53cb4189d8
893 changed files with 19533 additions and 42 deletions

View File

@@ -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;
};
}

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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))

View File

@@ -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);
}
}