def unregister_tile(self, pageName: str, tile: Tile): fullName = self.get_full_name(pageName, tile.get_uniqueName()) if fullName not in self.__jobs: LOGGER.warning(f'Tile "{fullName}" is not registered') self.__jobs[fullName].remove() del self.__jobs[fullName] del self.__cache[fullName] del self.__tiles[fullName] LOGGER.debug(f'Unregistered "{fullName}"')
def register_tile(self, pageName: str, tile: Tile): fullName = self.get_full_name(pageName, tile.get_uniqueName()) if fullName in self.__jobs: LOGGER.warning(f'Tile "{fullName}" already registered') return seconds = tile.get_intervalInSeconds() nextRunTime = datetime.now() if seconds == -1: # disable automatic refresh seconds = 9999999999 # 317 years nextRunTime = None # job is paused job = self.__scheduler.add_job(tile.update, 'interval', [pageName], seconds=seconds, next_run_time=nextRunTime) self.__jobs[fullName] = job self.__cache[fullName] = None self.__tiles[fullName] = tile LOGGER.debug(f'Registered "{fullName}" (scheduled every {tile.get_intervalInSeconds()} seconds)')