def add_watcher(self, name, cmd, **kw): """Adds a watcher. Options: - **name**: name of the watcher to add - **cmd**: command to run. - all other options defined in the Watcher constructor. """ if name in self._watchers_names: raise AlreadyExist("%r already exist" % name) if not name: return ValueError("command name shouldn't be empty") watcher = Watcher(name, cmd, **kw) watcher.initialize(self.evpub_socket, self.sockets) self.watchers.append(watcher) self._watchers_names[watcher.name.lower()] = watcher return watcher
def add_show(self, show): with self._lock: if show.name in self._shows_names: raise AlreadyExist("%r already exist" % show.name) self.shows.append(show) self._shows_names[show.name] = show