From e35e42911563de6380ea33b16cdf175f63518ba0 Mon Sep 17 00:00:00 2001 From: Killian Hutchinson <36945075+Ummoon@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:43:26 +0200 Subject: [PATCH] Fixed issue with the wrapper Inspired from https://github.com/randombk/df-obsidian/blob/master/dfhack_remote.py --- dfhack_remote.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dfhack_remote.py b/dfhack_remote.py index a1627aa..a9977e6 100644 --- a/dfhack_remote.py +++ b/dfhack_remote.py @@ -86,12 +86,11 @@ async def GetVersion(output: StringMessage = None): from inspect import signature input, output, function, _plugin = None, None, None, None - async def wrapper(*args, **kwds): + async def wrapper(requestData = None): #if isinstance(plugin, str): # kwds['plugin'] = plugin - _id = await BindMethod(function.__name__, input, output, plugin=_plugin, **kwds) - - _writer.write( request(_id, input()) ) + _id = await BindMethod(function.__name__, input, output, _plugin) + _writer.write( request(_id, requestData or input())) id, size = await get_header() if id == DFHackReplyCode.RPC_REPLY_RESULT: @@ -104,6 +103,13 @@ async def wrapper(*args, **kwds): obj = output() obj.ParseFromString(buffer) return obj + elif id == DFHackReplyCode.RPC_REPLY_TEXT: + msg = await _reader.read(size) + obj = CoreProtocol_pb2.CoreTextNotification() + obj.ParseFromString(msg) + raise Exception(obj) + else: + raise Exception(f"Unknown reply code {id}") def parse(f): nonlocal input, output, function