mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Log python plugin error.
This commit is contained in:
@@ -40,19 +40,20 @@ namespace Wox.PluginLoader
|
|||||||
PythonResult ps = pythonResult;
|
PythonResult ps = pythonResult;
|
||||||
if (!string.IsNullOrEmpty(ps.ActionName))
|
if (!string.IsNullOrEmpty(ps.ActionName))
|
||||||
{
|
{
|
||||||
ps.Action = (context) => InvokeFunc(ps.ActionName, GetPythonActionContext(context),new PyString(ps.ActionPara));
|
ps.Action = (context) => InvokeFunc(ps.ActionName, GetPythonActionContext(context), new PyString(ps.ActionPara));
|
||||||
}
|
}
|
||||||
r.Add(ps);
|
r.Add(ps);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Log.Error(string.Format("Python Plugin {0} query failed: {1}", metadata.Name, e.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new List<Result>();
|
return new List<Result>();
|
||||||
@@ -73,11 +74,19 @@ namespace Wox.PluginLoader
|
|||||||
|
|
||||||
private string InvokeFunc(string func, params PyObject[] paras)
|
private string InvokeFunc(string func, params PyObject[] paras)
|
||||||
{
|
{
|
||||||
string json;
|
string json = null;
|
||||||
|
|
||||||
IntPtr gs = PythonEngine.AcquireLock();
|
IntPtr gs = PythonEngine.AcquireLock();
|
||||||
|
|
||||||
PyObject module = PythonEngine.ImportModule(moduleName);
|
PyObject module = PythonEngine.ImportModule(moduleName);
|
||||||
|
if (module == null)
|
||||||
|
{
|
||||||
|
string error = string.Format("Python Invoke failed: {0} doesn't has module {1}",
|
||||||
|
metadata.ExecuteFilePath,moduleName);
|
||||||
|
Log.Error(error);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
if (module.HasAttr(func))
|
if (module.HasAttr(func))
|
||||||
{
|
{
|
||||||
PyObject res = paras.Length > 0 ? module.InvokeMethod(func, paras) : module.InvokeMethod(func);
|
PyObject res = paras.Length > 0 ? module.InvokeMethod(func, paras) : module.InvokeMethod(func);
|
||||||
|
|||||||
Reference in New Issue
Block a user