本文整理汇总了Python中program.Program.getDenyReason方法的典型用法代码示例。如果您正苦于以下问题:Python Program.getDenyReason方法的具体用法?Python Program.getDenyReason怎么用?Python Program.getDenyReason使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类program.Program
的用法示例。
在下文中一共展示了Program.getDenyReason方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DfpnSolver
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import getDenyReason [as 别名]
class DfpnSolver(Thread):
class Error:
pass
def __init__(self, name, command, positions, verbose):
Thread.__init__(self)
self._name = name
self._positions = positions
self._verbose = verbose
command = command + " --logfile-name=" + name + ".log"
self._program = Program(command, verbose)
def sendCommand(self, command):
try:
return self._program.sendCommand(command);
except Program.CommandDenied:
reason = self._program.getDenyReason()
self._errorMessage = _name + ": " + reason
raise DfpnSolver.Error
except Program.Died:
self._errorMessage = _name + ": program died"
raise DfpnSolver.Error
def playVariation(self, variation):
self.sendCommand("clear_board");
moves = variation.split(' ');
color = "B";
for move in moves:
cmd = "play " + color + " " + move.strip();
self.sendCommand(cmd);
if color == "B":
color = "W";
else:
color = "B";
def solvePosition(self, variation):
if (self._verbose):
print "#####################################"
print self._name + ": " + variation
print "#####################################"
else:
print self._name + ": " + variation
self.playVariation(variation);
return self.sendCommand("dfpn-solve-state");
def addResult(self, variation, winner):
if (winner == "empty"):
f = open(self._name + ".unsolved", "a");
print >> f, variation;
f.close();
else:
f = open(self._name + ".solved", "a");
print >> f, variation + " " + winner
f.close();
def run(self):
while True:
variation = self._positions.getPosition();
if variation == "":
return;
else:
winner = self.solvePosition(variation).strip();
self.addResult(variation, winner);
print self._name + ": " + winner