def execute(self, code: str, message: Message) -> CodeOutput:
dmepath = await self.make_project(code)
proc = await create_subprocess_exec("DreamMaker", dmepath, stdout=asyncio.subprocess.PIPE) # type: asyncio.Process
await proc.wait()
data = await proc.stdout.read() # type: bytes
compile_log = data.decode("ascii") # type: str
out = CodeOutput() # type: CodeOutput
out.compile_output = compile_log
if proc.returncode:
out.state = CodeHandlerState.failed_compile
return out
else:
out.state = CodeHandlerState.compiled
proc = await create_subprocess_exec("DreamDaemon", dmepath + "b", stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
await proc.wait()
data = await proc.stderr.read() + await proc.stdout.read()
log = data.decode("ascii") # type: str
out.output = log
return out
评论列表
文章目录