← Back to team overview

sikuli-driver team mailing list archive

[Question #286187]: Custom Wrapper Firing Twice

 

New question #286187 on Sikuli:
https://answers.launchpad.net/sikuli/+question/286187

I have been trying to get a more generic wrapper than that found here: http://blog.mykhailo.com/2011/02/how-to-sikuli-and-robot-framework.html

I've got something, but it looks like I'm running into the same problem stated in comment #4 at https://answers.launchpad.net/sikuli/+question/225697 . 


Here is my code:

###decorator.py###
from decorator2 import *
click("white.png")
r = Region(231,123,1449,904)
r.click("white.png")


###decorator2.py###
import sikuli.Sikuli
from sikuli.Sikuli import Region as SikuliRegion
    
def some_decorator(func):
    def wrapper(*args, **kwargs):
        print "*********in wrapper************"
        print "Arguments were: %s, %s" % (args, kwargs)
        return func(*args, **kwargs)
    return wrapper

click = some_decorator(sikuli.Sikuli.click)

class Region(SikuliRegion):
    click = some_decorator(sikuli.Sikuli.Region.click)


Here is the output:
*********in wrapper************
Arguments were: ('white.png',), {}
[log] CLICK on L(1723,70)@S(0)[0,0 1920x1080]
*********in wrapper************
Arguments were: (R[231,123 1449x904]@S(0)[0,0 1920x1080] E:Y, T:3.0, 'white.png'), {}
*********in wrapper************
Arguments were: (R[231,123 1449x904]@S(0)[0,0 1920x1080] E:Y, T:3.0, u'white.png', 0), {}
[log] CLICK on L(491,136)@S(0)[0,0 1920x1080]


Why does the wrapper get called twice, and why does the arguments change between the Screen and the region, and between the two region lines?

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