← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #141103]: How to get string of PS into FindFailed exception clause

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Not a feature in the moment, you should post a [feature request] bug:
match should know it's pattern.

Since I "hated" FindFailed from beginning, I requested exists() ... and
got it ;-)

Solution with exists (works with try: except: as well ;-)

img = Pattern or string
if exists(img): click(getLastMatch())
else: print "FindFailed:", img; exit(1)

with exists() you might even go on in your script and take corrective
actions in case of FindFailed.

Tip:
for such simple constructs like 

try:
   click(PS)
except FindFailed:
   ?? how to get str(PS) here??

I use to make it more readable:

try: click(PS)
except: print "error"; exit(1)

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