def trigger(self, msg=None): """This is the method you must call when you want to trigger this Event. """ self.triggering.acquire() if self.triggered: return if msg is not None: self.msg = msg if self.group is not None: self.group.triggerCallback() triggerEvent( self.ID ) self.triggered = True self.triggering.release()
def __cmd_trigger(self, *args): if len(args) != 1: raise Exception("Trigger command needs an event string or an event's id.") plug,event,others = parsesubs(args[0]) if len(others)>0: raise Exception("Invalid event string or id.") try: if event is None: #could be either an id or just a plug name. pid = self.registry.getAttachId(plug) eids = self.registry.getPlugEventIds(pid) if len(eids)==0: eid = self.registry.getEventId(plug) if eid is None: raise Exception() else: eids.append(eid) for eid in eids: triggerEvent(eid) else: #must be an event string pid = self.registry.getAttachId(plug) eid = self.registry.getPlugEventId(pid, event) if eid is not None: triggerEvent(eid) else: raise Exception("Could not find the given event to trigger!") return "Triggered!" except Exception as e: logging.exception(e) raise e #explicit re-raise