dm.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:MoMMI 作者: PJB3005 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号