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

I'm currently in the middle of a script used to observe many regions at once, 
all pointed at IP camera feeds. The script is to see if any of the screens 
shown on the feeds go dark at any given moment. 

I've used a class to create all of my onAppear and observeInBackground methods 
since they all follow the same process, and gave the __init__ arguments of 
'self', 'name', and 'region'. I was hoping to make another method that would be 
used as the handler for these onAppears called 'trigger_handler', that would 
alert us as to which region has been triggered when it happens (see below).


def trigger_handler(self, event):
        ###
        # This is the method that gets called whenever the onAppear observation 
is triggered. Health check will send with the 
        subject 
        line noting which screen is down and send both pictures
        ###
        popup(self.name+" appears to be down, can you confirm?")

My idea was to reference this method as the handler in the onAppear method (see 
below), but when doing so the handler triggers immediately whether the onAppear 
is true or not.


def start_observe(self, reference):
        ### 
        # This is the method assigned to each region being observed that looks 
for its own reference image and calls its own event 
        handler when triggered  
        ###
        reference = str(self.region)+"_out"
        self.region.onAppear(reference, self.trigger_handler())
        self.region.observeInBackground(FOREVER)  


I'm also pasting the class itself and the __init__ that directly follows just 
for reference, and also a couple of the class objects below that.

Thank you so much for any help and advice, I am just totally stumped!



class event_handler():
    ### 
    # This is a class that contains all handlers for observation regions. The 
__init__ helps us define the name of the screen we are 
    currently observing,
    # while the trigger_handler method is assigned to all objects of the class 
and gets called for that specific object when the 
    onAppear gets triggered 
    ###
    def __init__(self, name, region):
        self.name = name
        self.region = region



rr02_handler = event_handler("Reader Rail 2", rr02)  ###(rr02 and rr08 are 
regions defined earlier on before the class.
rr08_handler = event_handler("Reader Rail 8", rr08)

def start_all_observe():
    rr02_handler.start_observe(rr02_out)

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to