get_action(...) and BotFail - ArtemisFowlJnr/KotH GitHub Wiki
Syntax:
def get_action(filename, retry=1, timeout=5,
validate=lambda _, _: True, get_input=lambda _: ''):
Parameters:
filename- the name of the file to runretry- the maximum number of times to rerun the program if we don't get an valid output (including the first try). If it is 0, we run forevertimeout- the maximum time, in seconds, to give a program to runvalidate- a function that should accept the filename and output, and return boolean to indicate wether or not the output was valid. The default always returns Trueget_input- a function that, given the filname, returns a string to pass to the program. Default returns empty string
Output
It returns either the action, if it got a successful one, or an instanc of the BotFail class, containing details.
BotFail
Contains four fields:
filename- the filename of the failed bottimeout- True if the bot ran out of time on its last run, False otherwiseerror- None if the bot did not give an error last run, the error (a string) otherwiseinvalid- True if the bot gave an invalid response last run, False otherwise