proc = SubProcess("python", [ os.path.expanduser("~") + "/pychess/lib/pychess/Players/PyChess.py", ]) create_task(self.parse_line(proc)) print("xboard", file=proc) print("protover 2", file=proc) @asyncio.coroutine def parse_line(self, proc): while True: line = yield from wait_signal(proc, 'line') if line: print(' parse_line:', line[1]) else: print("no more lines") break def on_quit(self, action, param): self.quit() if __name__ == "__main__": from pychess.external import gbulb gbulb.install(gtk=True) app = Application() loop = asyncio.get_event_loop() loop.set_debug(enabled=True) loop.run_forever(application=app)
self.window.present() def on_subprocess(self, action, param): proc = SubProcess("python", [os.path.expanduser("~") + "/pychess/lib/pychess/Players/PyChess.py", ]) asyncio.async(self.parse_line(proc)) print("xboard", file=proc) print("protover 2", file=proc) @asyncio.coroutine def parse_line(self, proc): while True: line = yield from wait_signal(proc, 'line') if line: print(' parse_line:', line[1]) else: print("no more lines") break def on_quit(self, action, param): self.quit() if __name__ == "__main__": from pychess.external import gbulb gbulb.install(gtk=True) app = Application() loop = asyncio.get_event_loop() loop.set_debug(enabled=True) loop.run_forever(application=app)
command = Command(engine_command, "xboard\nprotover 2\nquit\n") status, output, err = command.run(timeout=5) cecp = False for line in output.splitlines(): line = line.rstrip() if "feature" in line and "done" in line: cecp = True break elif "Error" in line or "Illegal" in line or "Invalid" in line: break return cecp if __name__ == "__main__": from pychess.external import gbulb gbulb.install() loop = asyncio.get_event_loop() def discovering_started(discoverer, names): print("discovering_started", names) discoverer.connect("discovering_started", discovering_started) def engine_discovered(discoverer, name, engine): sys.stdout.write(".") discoverer.connect("engine_discovered", engine_discovered) def all_engines_discovered(discoverer): print("all_engines_discovered") print([engine["name"] for engine in discoverer.getEngines()])