diff --git a/Plugins/Wox.Plugin.Kill/main.py b/Plugins/Wox.Plugin.Kill/main.py
index 44db261bdf..d8ea72c3dd 100644
--- a/Plugins/Wox.Plugin.Kill/main.py
+++ b/Plugins/Wox.Plugin.Kill/main.py
@@ -27,7 +27,7 @@ def query(key):
pass
return json.dumps(results)
-def killProcess(pid):
+def killProcess(context,pid):
p = psutil.Process(int(pid))
if p:
p.kill()
diff --git a/Plugins/Wox.Plugin.V2ex/main.py b/Plugins/Wox.Plugin.V2ex/main.py
index ef3a1a504d..cc118d4883 100644
--- a/Plugins/Wox.Plugin.V2ex/main.py
+++ b/Plugins/Wox.Plugin.V2ex/main.py
@@ -27,7 +27,7 @@ def query(key):
results.append(res)
return json.dumps(results)
-def openUrl(url):
+def openUrl(context,url):
webbrowser.open(url)
if __name__ == "__main__":
diff --git a/Wox/Helper/WoxPythonException.cs b/Wox/Helper/WoxPythonException.cs
new file mode 100644
index 0000000000..7a3b8239fb
--- /dev/null
+++ b/Wox/Helper/WoxPythonException.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Wox.Helper
+{
+ public class WoxPythonException : WoxException
+ {
+ public WoxPythonException(string msg) : base(msg)
+ {
+ }
+ }
+}
diff --git a/Wox/PluginLoader/PythonPluginWrapper.cs b/Wox/PluginLoader/PythonPluginWrapper.cs
index 96976e2879..e161a42c77 100644
--- a/Wox/PluginLoader/PythonPluginWrapper.cs
+++ b/Wox/PluginLoader/PythonPluginWrapper.cs
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Windows.Documents;
using Newtonsoft.Json;
using Python.Runtime;
using Wox.Helper;
@@ -13,7 +10,6 @@ namespace Wox.PluginLoader
{
public class PythonPluginWrapper : IPlugin
{
-
private PluginMetadata metadata;
private string moduleName;
@@ -50,7 +46,7 @@ namespace Wox.PluginLoader
{
#if (DEBUG)
{
- throw;
+ throw new WoxPythonException(e.Message);
}
#endif
Log.Error(string.Format("Python Plugin {0} query failed: {1}", metadata.Name, e.Message));
@@ -82,15 +78,29 @@ namespace Wox.PluginLoader
if (module == null)
{
string error = string.Format("Python Invoke failed: {0} doesn't has module {1}",
- metadata.ExecuteFilePath,moduleName);
+ metadata.ExecuteFilePath, moduleName);
Log.Error(error);
return json;
}
if (module.HasAttr(func))
{
- PyObject res = paras.Length > 0 ? module.InvokeMethod(func, paras) : module.InvokeMethod(func);
- json = Runtime.GetManagedString(res.Handle);
+ try
+ {
+ PyObject res = paras.Length > 0 ? module.InvokeMethod(func, paras) : module.InvokeMethod(func);
+ json = Runtime.GetManagedString(res.Handle);
+ }
+ catch (Exception e)
+ {
+ string error = string.Format("Python Invoke failed: {0}", e.Message);
+ Log.Error(error);
+#if (DEBUG)
+ {
+ throw new WoxPythonException(error);
+ }
+#endif
+ }
+
}
else
{
@@ -99,7 +109,7 @@ namespace Wox.PluginLoader
Log.Error(error);
#if (DEBUG)
{
- throw new ArgumentException(error);
+ throw new WoxPythonException(error);
}
#endif
}
diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj
index acc1016fc2..1e2dfba0ab 100644
--- a/Wox/Wox.csproj
+++ b/Wox/Wox.csproj
@@ -132,6 +132,7 @@
+
HotkeyControl.xaml