Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions dfhack_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down