def initEngine(self, xmlengine, color): protover = int(xmlengine.get("protover")) protocol = xmlengine.get("protocol") path = xmlengine.find('path').text.strip() args = [a.get('value') for a in xmlengine.findall('args/arg')] if xmlengine.find('vm') is not None: vmpath = xmlengine.find('vm/path').text.strip() vmargs = [a.get('value') for a in xmlengine.findall('vm/args/arg')] args = vmargs + [path] + args path = vmpath warnwords = ("illegal", "error", "exception") subprocess = SubProcess(path, args, warnwords, SUBPROCESS_SUBPROCESS) engine = attrToProtocol[protocol](subprocess, color, protover) if protocol == "uci": # If the user has configured special options for this engine, here is # where they should be set. def optionsCallback(engine): if engine.hasOption("OwnBook"): engine.setOption("OwnBook", True) engine.connect("readyForOptions", optionsCallback) return engine
async def initEngine(self, engine, color, lowPriority): name = engine['name'] protocol = engine["protocol"] protover = 2 if engine.get("protover") is None else engine.get( "protover") path = engine['command'] args = [] if engine.get('args') is None else [ a for a in engine['args'] ] if engine.get('vm_command') is not None: vmpath = engine['vm_command'] vmargs = [] if engine.get('vm_args') is None else [ a for a in engine['vm_args'] ] args = vmargs + [path] + args path = vmpath md5_engine = engine['md5'] working_directory = engine.get("workingDirectory") if working_directory: workdir = working_directory else: workdir = getEngineDataPrefix() warnwords = ("illegal", "error", "exception") try: subprocess = SubProcess(path, args=args, warnwords=warnwords, cwd=workdir, lowPriority=lowPriority) await subprocess.start() except OSError: raise PlayerIsDead except asyncio.TimeoutError: raise PlayerIsDead except GLib.GError: raise PlayerIsDead except Exception: raise PlayerIsDead engine_proc = attrToProtocol[protocol](subprocess, color, protover, md5_engine) engine_proc.setName(name) # If the user has configured special options for this engine, here is # where they should be set. def optionsCallback(set_option): if engine.get("options"): for option in engine["options"]: key = option["name"] value = option.get("value") if (value is not None) and option["default"] != value: if protocol == "xboard" and option["type"] == "check": value = int(bool(value)) set_option.setOption(key, value) engine_proc.connect("readyForOptions", optionsCallback) return engine_proc
def start(self): assert not self.subproc if sys.platform == "win32": args = ["-t", self.host] else: args = ["-i10", self.host] self.subproc = SubProcess(searchPath("ping"), args, env={"LANG": "en"}) self.conid1 = self.subproc.connect("line", self.__handleLines) self.conid2 = self.subproc.connect("died", self.__handleDead)
def initEngine(self, engine, color): name = engine['name'] protocol = engine["protocol"] protover = 2 if engine.get("protover") is None else engine.get( "protover") path = engine['command'] args = [] if engine.get('args') is None else [ a for a in engine['args'] ] if engine.get('vm_command') is not None: vmpath = engine['vm_command'] vmargs = [] if engine.get('vm_args') is None else [ a for a in engine['vm_args'] ] args = vmargs + [path] + args path = vmpath md5 = engine['md5'] working_directory = engine.get("workingDirectory") if working_directory: workdir = working_directory else: workdir = getEngineDataPrefix() warnwords = ("illegal", "error", "exception") subprocess = SubProcess(path, args, warnwords, SUBPROCESS_SUBPROCESS, workdir) engine_proc = attrToProtocol[protocol](subprocess, color, protover, md5) engine_proc.setName(name) # If the user has configured special options for this engine, here is # where they should be set. def optionsCallback(e): if engine.get("options"): for option in engine["options"]: key = option["name"] value = option.get("value") if (value is not None) and option["default"] != value: if protocol == "xboard" and option["type"] == "check": value = int(bool(value)) e.setOption(key, value) engine_proc.connect("readyForOptions", optionsCallback) return engine_proc
def start(self): assert not self.subproc self.subproc = SubProcess(searchPath("ping"), [self.host], env={"LANG": "en"}) self.conid1 = self.subproc.connect("line", self.__handleLines) self.conid2 = self.subproc.connect("died", self.__handleDead)