From ecce9a5051d34f5f5eb92ac22f89e1817f7e8b59 Mon Sep 17 00:00:00 2001 From: EzFeDezy Date: Mon, 26 May 2025 18:03:59 +0200 Subject: [PATCH] Bugfix regarding callbackInfos --- src/Indexer/Models/Script.cs | 4 ++-- src/Indexer/Scripts/example.py | 5 +++-- src/Indexer/Scripts/tools.py | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Indexer/Models/Script.cs b/src/Indexer/Models/Script.cs index 851c216..dc93198 100644 --- a/src/Indexer/Models/Script.cs +++ b/src/Indexer/Models/Script.cs @@ -35,7 +35,7 @@ public class PythonScriptable : IScriptable } Init(); } - + public void Init() { using (Py.GIL()) @@ -52,8 +52,8 @@ public class PythonScriptable : IScriptable PythonEngine.Initialize(); using (Py.GIL()) { - ToolSet.callbackInfos = callbackInfos; pyToolSet = ToolSet.ToPython(); + pyToolSet.SetAttr("callbackInfos", callbackInfos.ToPython()); scope.Set("toolset", pyToolSet); scope.Exec("update(toolset)"); } diff --git a/src/Indexer/Scripts/example.py b/src/Indexer/Scripts/example.py index 338910e..522dd9d 100644 --- a/src/Indexer/Scripts/example.py +++ b/src/Indexer/Scripts/example.py @@ -24,10 +24,11 @@ def update(toolset: Toolset): print("Py-DEBUG@update") print("This is the update function from the python example script") callbackInfos:ICallbackInfos = toolset.callbackInfos - if (callbackInfos is IntervalCallbackInfos): + if (str(callbackInfos) == "Indexer.Models.IntervalCallbackInfos"): print("It was called via an interval callback") + else: + print("It was called, but the origin of the call could not be determined") example_counter += 1 - mycounter = example_counter print(f"example_counter: {example_counter}") index_files(toolset) diff --git a/src/Indexer/Scripts/tools.py b/src/Indexer/Scripts/tools.py index d7dd763..fc5722e 100644 --- a/src/Indexer/Scripts/tools.py +++ b/src/Indexer/Scripts/tools.py @@ -112,14 +112,15 @@ class Client: pass async def EntityDeleteAsync(searchdomain:str, entityName:str) -> EntityDeleteResults: pass + +@dataclass class ICallbackInfos: pass - @dataclass class IntervalCallbackInfos(ICallbackInfos): sender: Optional[object] - e: object + e: object @dataclass class Toolset: