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

RaiMan proposed the following answer:
Yes is possible by evaluating the stack trace.
But to get it, you first need an exception:

import traceback
def xclick(img):
   if exists(img):
      click(getLastMatch())
   else:
      try: raise TypeError
      except TypeError:
         tb = sys.exc_info()[2]
         tbinfo = traceback.extract_tb(sys.exc_info()[2])
         print tbinfo # should print a list with entries like 
         # (filename, line number, function name, some text)
      print '[Error] Image not found: ' + img + ' on line' + LINE_NUMBER
      exit(1)

But in this case, since you are aborting your script, if the image is
not found, why not use:

def xclick(img):
     click(img)

if the search fails, the script will be aborted with exception find
failed and you get your stack trace and the line numbers.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which 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