Question #670456 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/670456

Description changed to:
************************* This works after having fixed some issues:

Using
FindFailed.setHandler(ffhandler)
takes care, that every Region created thereafter inherits the setting (handler 
will be visited on FindFailed)

In Jython/Jruby scripting:
If you want this behaviour for the standard SCREEN object too, you either have 
to issue a
use()
after the global setting or use
setFindFailedHandler(ffhandler)

The latter one is the only to use, if you want the behaviour only for
the global SCREEN object.

Be aware:
If you do not want your script to abort after returning from the handler, you 
have to issue
event.setResponse(SKIP)
in the handler before the return.
Depending on what you have done in the handler, one of the other options RETRY 
or PROMPT might make sense as well.

------------------------------------------------------------------------------------------------------------

Let's assume I have a rather lengthy SikuliX script that can basically fail at 
any point - usually find failed.
Instead of modifying the whole script to catch every possible error, my idea 
was to use some kind of "supervisor" script instead.
The supervisor calls the script and if anything goes wrong there, the GUI in 
question is reset to its initial state by the supervisor which then calls the 
script again.
I got this idea working, but of course every time a find failed occurs in the 
called script everything comes to a stop.
What I would need is a way to simply exit a script (so the supervisor can take 
over) every time a find failed occurs. Is this possible?

"setFindFailedResponse()" doesn't seem to have the proper parameters for what I 
have in mind.
Setting it to "SKIP" won't do it because if an error occurs, the GUI HAS to be 
reset to its initial state.

Edit: tried using setFindFailedHandler:
setFindFailedHandler(resetGUI)
def resetGUI():
    #do stuff
#rest of the script

Still, the script just stops when encountering a FindFailed error
instead of calling my resetGUI routine. In addition to that, I still
have the problem that I would need to start the script at the beginning,
no matter where an error occured.

Edit2: I am running SikuliX version 1.1.2 on Windows10. Yet even putting 
"setFindFailedResponse(SKIP)" in the header, the script still throws an 
exception when an image is not found...
...apparently, setFindFailedResponse gets overwritten by setFindFailedHandler. 
But still, my handler function is not executed when a FindFailed occurs.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to