← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #205413]: trying to trap errors in sikili script not quite working

 

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

    Status: Answered => Open

ironmantis7x is still having a problem:
I am still not getting the app to exit on a fail.  It seems to fail on the step afterwards which is a wait for image to appear step eventhough it can't find the image.
Any ideas??

ironmantis7x
 
----------------------------------------------------
Lizard (#4): Leave it to my friend.  He can do it!
Scorpion (#3): And who is your friend?
Lizard (#4):  A first class kung fu man; an expert!


________________________________
 From: RaiMan <question205413@xxxxxxxxxxxxxxxxxxxxx>
To: ironmantis7x@xxxxxxxxx 
Sent: Thursday, August 9, 2012 10:06 AM
Subject: Re: [Question #205413]: trying to trap errors in sikili script not quite working
 
Your question #205413 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/205413

    Status: Open => Answered

RaiMan proposed the following answer:
If the standards are in effect, find() will abort the script if not
found.

exists() always returns with either None (which is false) or the match
object (which is true). So exists() usually is the first choice to check
wether something is there, before going on.

your case:

# find("1344004317402.png") # delete it - does not make sense, you use exists
if not exists("1344004317402.png"):
    print"[error]: Can't Start Application"
    exit(1)
else: # not needed here, since script will end if not found anyway
click("1344004329798.png") # next statement, if above image is found

so what is left:
if not exists("1344004317402.png"):
    print"[error]: Can't Start Application"
    exit(1)
click("1344004329798.png") 

Another trick, to make the script robust:

if not exists(some_image): print "problem"; exit(1)
click(getLastMatch()) # no additional search, if the image just found should be clicked

-- 
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/sikuli/+question/205413/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/sikuli/+question/205413

You received this question notification because you asked the question.

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.