sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #37221
Re: [Question #288553]: Taking a printscreen if an error occurs
Question #288553 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/288553
Status: Open => Answered
RaiMan proposed the following answer:
--- Could I setup the exception as a function?
no, not possible.
the proposal has the following restriction:
having this as suggested:
try:
func1()
func2()
func3()
except ZeroDivisionError:
print "ZeroDivisionError"
except FindFailed:
type(Key.PRINTSCREEN)
will terminate after the first catched exeception and does not continue
with the next function call.
... but you can define your own guarded find:
def myFind(img, reg = None):
try:
if reg:
m = reg.find(img)
else:
m = find(img)
except:
# here you can do your screenshot and write your log
m = None
return m
myFind(img1) # search on whole screen
myFind(img1, someRegion) # search in region
... but no need to do it with find:
def myFind(img, reg = None):
if reg:
m = reg.exists(img)
else:
m = exists(img)
if not m:
# here you can do your screenshot and write your log
return m
same usage:
myFind(img1) # search on whole screen
myFind(img1, someRegion) # search in region
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.