'findAll(): 'NoneType' object is not iterable' due to inconsistent image recognition?
I have written a script in SikuliIDE 1.1.0 nightly on an up-to-date Arch Linux system. The script works, well, kind of. It is supposed to run indefinitely but every now and then it stops and throws a 'findAll(): 'NoneType' object is not iterable'.
The script is meant to check the screen for random numbers (between 75-108) in a specific location, recognizing the numerical value, clicking one button on the screen ('store') if it happens to be the highest number as of yet, and keep clicking on another button ('reroll') on the screen to generate a new random number. The idea is to keep going until the user stops the script while storing the highest number along the way.
The script is using cropped images of the numbers as they might appear on the screen. A loop checks for the respective image of every number, then uses findAll() to see how many occurances it can find, then sorts them according to their X coordinate and finally puts them together and converts them to an integer. Then it starts over again.
numbPattern = [(0,"num0.
for i in range(0, 9):
y = i
for n in range(len(
Sometimes numbers don't get recognized correctly (due to my script, not due to Sikuli); eg. 84 on the screen would be recognized as 804 by my script. However, this only happens from time to time. Usually the image recognition is consistent. Numbers above 108 are simply omitted by the script (a not so elegant solution, but still).
I suspect that sometimes 'exists' in the for loop finds a certain number, but then findAll() fails to find it (one or more occurances) and thus 'findAll(): 'NoneType' object is not iterable' terminates the running script. This is due to Sikuli which doesn't recognize the number images consistently.
How can this be avoided? I hope that my explanation is understandable. My apologies in advance if this code makes any veteran programmer nauseous.