uci.py 文件源码

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

项目:jcchess 作者: johncheetham 项目源码 文件源码
def read_stdout(self): 
        while True:
            try:
                e = ("<-" + self.side + "(" +
                     self.get_running_engine().strip() + "):")
                line= ""
                # python2 line = unicode(self.p.stdout.readline(), errors ='ignore')
                    # or: 'your iso 8859-15 text'.decode('iso8859-15')
                # python3 (doesn't work) lineb = self.p.stdout.readline().encode("utf-8", "ignore")
                #print(lineb)
                #line = str(lineb)
                #print(line, "line")
                line = self.p.stdout.readline()

                if line == "":
                    if gv.verbose:
                        print(e + "eof reached")
                    if gv.verbose:
                        print(e + "stderr:", self.p.stderr.read())
                    break
                #line = line[2:-3]
                #print(line)
                line = line.strip()

                if gv.verbose or gv.verbose_uci:
                    print(e + line)
                GObject.idle_add(self.engine_debug.add_to_log, e+line)
                if line.startswith("info"):
                    GObject.idle_add(
                        self.engine_output.add_to_log, self.side,
                        self.get_running_engine().strip(), line)
                self.op.append(line)
            except Exception as e:
                # line = e + "error"
                print("subprocess error in uci.py read_stdout:", e, "at:", line)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号