mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Temp fix for #667 by add wox.py to PYTHONPATH
This commit is contained in:
parent
4b31f40026
commit
a8869c46b8
7 changed files with 35 additions and 115 deletions
|
|
@ -1,107 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
import json
|
||||
import sys
|
||||
import inspect
|
||||
|
||||
class Wox(object):
|
||||
"""
|
||||
Wox python plugin base
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
rpc_request = json.loads(sys.argv[1])
|
||||
self.proxy = rpc_request.get("proxy",{})
|
||||
request_method_name = rpc_request.get("method")
|
||||
request_parameters = rpc_request.get("parameters")
|
||||
methods = inspect.getmembers(self, predicate=inspect.ismethod)
|
||||
|
||||
request_method = dict(methods)[request_method_name]
|
||||
results = request_method(*request_parameters)
|
||||
if request_method_name == "query":
|
||||
print(json.dumps({"result": results}))
|
||||
|
||||
def query(self,query):
|
||||
"""
|
||||
sub class need to override this method
|
||||
"""
|
||||
return []
|
||||
|
||||
def debug(self,msg):
|
||||
"""
|
||||
alert msg
|
||||
"""
|
||||
print("DEBUG:{}".format(msg))
|
||||
sys.exit()
|
||||
|
||||
class WoxAPI(object):
|
||||
|
||||
@classmethod
|
||||
def change_query(cls,query,requery = False):
|
||||
"""
|
||||
change wox query
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.ChangeQuery","parameters":[query,requery]}))
|
||||
|
||||
@classmethod
|
||||
def shell_run(cls,cmd):
|
||||
"""
|
||||
run shell commands
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.ShellRun","parameters":[cmd]}))
|
||||
|
||||
@classmethod
|
||||
def close_app(cls):
|
||||
"""
|
||||
close wox
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.CloseApp","parameters":[]}))
|
||||
|
||||
@classmethod
|
||||
def hide_app(cls):
|
||||
"""
|
||||
hide wox
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.HideApp","parameters":[]}))
|
||||
|
||||
@classmethod
|
||||
def show_app(cls):
|
||||
"""
|
||||
show wox
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.ShowApp","parameters":[]}))
|
||||
|
||||
@classmethod
|
||||
def show_msg(cls,title,sub_title,ico_path=""):
|
||||
"""
|
||||
show messagebox
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.ShowMsg","parameters":[title,sub_title,ico_path]}))
|
||||
|
||||
@classmethod
|
||||
def open_setting_dialog(cls):
|
||||
"""
|
||||
open setting dialog
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.OpenSettingDialog","parameters":[]}))
|
||||
|
||||
@classmethod
|
||||
def start_loadingbar(cls):
|
||||
"""
|
||||
start loading animation in wox
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.StartLoadingBar","parameters":[]}))
|
||||
|
||||
@classmethod
|
||||
def stop_loadingbar(cls):
|
||||
"""
|
||||
stop loading animation in wox
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.StopLoadingBar","parameters":[]}))
|
||||
|
||||
@classmethod
|
||||
def reload_plugins(cls):
|
||||
"""
|
||||
reload all wox plugins
|
||||
"""
|
||||
print(json.dumps({"method": "Wox.ReloadPlugins","parameters":[]}))
|
||||
|
|
@ -20,6 +20,7 @@ namespace Wox.Core.Plugin
|
|||
internal abstract class JsonRPCPlugin : IPlugin
|
||||
{
|
||||
protected PluginInitContext context;
|
||||
public const string JsonRPC = "JsonRPC";
|
||||
|
||||
/// <summary>
|
||||
/// The language this JsonRPCPlugin support
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Wox.Core.Plugin
|
|||
return;
|
||||
}
|
||||
|
||||
string pluginFolerPath = Infrastructure.Constant.UserDirectory;
|
||||
string pluginFolerPath = Infrastructure.Constant.PluginsDirectory;
|
||||
|
||||
string newPluginName = plugin.Name
|
||||
.Replace("/", "_")
|
||||
|
|
|
|||
|
|
@ -33,13 +33,27 @@ namespace Wox.Core.Plugin
|
|||
// todo happlebao, this should not be public, the indicator function should be embeded
|
||||
public static PluginsSettings Settings;
|
||||
private static List<PluginMetadata> _metadatas;
|
||||
private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.UserDirectory };
|
||||
private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.PluginsDirectory };
|
||||
|
||||
private static void ValidateUserDirectory()
|
||||
{
|
||||
if (!Directory.Exists(Constant.UserDirectory))
|
||||
if (!Directory.Exists(Constant.PluginsDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(Constant.UserDirectory);
|
||||
Directory.CreateDirectory(Constant.PluginsDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeletePythonBinding()
|
||||
{
|
||||
const string binding = "wox.py";
|
||||
var directory = Constant.PluginsDirectory;
|
||||
foreach (var subDirectory in Directory.GetDirectories(directory))
|
||||
{
|
||||
var path = Path.Combine(subDirectory, binding);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +69,8 @@ namespace Wox.Core.Plugin
|
|||
static PluginManager()
|
||||
{
|
||||
ValidateUserDirectory();
|
||||
|
||||
// force old plugins use new python binding
|
||||
DeletePythonBinding();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Core.Plugin
|
||||
|
|
@ -17,8 +19,13 @@ namespace Wox.Core.Plugin
|
|||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true
|
||||
RedirectStandardError = true,
|
||||
};
|
||||
|
||||
// temp fix for issue #667
|
||||
var path = Path.Combine(Constant.ProgramDirectory, JsonRPC);
|
||||
_startInfo.EnvironmentVariables["PYTHONPATH"] = path;
|
||||
|
||||
}
|
||||
|
||||
protected override string ExecuteQuery(Query query)
|
||||
|
|
@ -30,6 +37,8 @@ namespace Wox.Core.Plugin
|
|||
};
|
||||
//Add -B flag to tell python don't write .py[co] files. Because .pyc contains location infos which will prevent python portable
|
||||
_startInfo.Arguments = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{request}\"";
|
||||
// todo happlebao why context can't be used in constructor
|
||||
_startInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;
|
||||
|
||||
return Execute(_startInfo);
|
||||
}
|
||||
|
|
@ -37,6 +46,7 @@ namespace Wox.Core.Plugin
|
|||
protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
|
||||
{
|
||||
_startInfo.Arguments = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{rpcRequest}\"";
|
||||
_startInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;
|
||||
return Execute(_startInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Wox.Infrastructure
|
|||
public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location).ToString();
|
||||
public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe");
|
||||
public static readonly string DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox);
|
||||
public static readonly string UserDirectory = Path.Combine(DataDirectory, Plugins);
|
||||
public static readonly string PluginsDirectory = Path.Combine(DataDirectory, Plugins);
|
||||
public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins);
|
||||
public static readonly string SettingsPath = Path.Combine(DataDirectory, Settings);
|
||||
public const string Github = "https://github.com/Wox-launcher/Wox";
|
||||
|
|
|
|||
|
|
@ -422,9 +422,10 @@
|
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\
|
||||
xcopy /Y /E $(ProjectDir)Themes\* $(TargetDir)Themes\
|
||||
xcopy /Y /E $(ProjectDir)Images\* $(TargetDir)Images\
|
||||
xcopy /Y /D /E $(SolutionDir)Plugins\HelloWorldPython\* $(TargetDir)Plugins\HelloWorldPython\*
|
||||
xcopy /Y /E $(SolutionDir)JsonRPC\* $(TargetDir)JsonRPC\
|
||||
|
||||
cd $(SolutionDir)packages\squirrel*\tools
|
||||
copy /Y Squirrel.exe $(TargetDir)..\Update.exe
|
||||
|
|
|
|||
Loading…
Reference in a new issue