From 14949c855fe660660bc5863702f554e85a950fa5 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Fri, 1 Jan 2021 13:54:02 +0100 Subject: [PATCH] #36 - allow tiles to disable automatic refresh by using "-1" as intervalInSeconds --- README.md | 2 +- src/logic/tile/TileScheduler.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1d3854b..ad42b1c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ The following snippet shows an example of a tile in the settings files. - `tileType` - References the name of a tile class. This class must exist on start of the server. - `uniqueName` - This name must be unique across the complete page. -- `intervalInSeconds` - Specifies the automatic refresh rate in seconds. +- `intervalInSeconds` - Specifies the automatic refresh rate in seconds (Use `-1` to disable automatic refresh). - `x` - Horizontal position in the grid, starting by 0 (**Note:** Positions should not be assigned more than once!) - `y` - Vertical position in the grid, starting by 0 (**Note:** Positions should not be assigned more than once!) - `width` - The tile's width (minimum is 1 maximum is 12 on desktop horizontal screens) diff --git a/src/logic/tile/TileScheduler.py b/src/logic/tile/TileScheduler.py index 01d361c..0474da5 100644 --- a/src/logic/tile/TileScheduler.py +++ b/src/logic/tile/TileScheduler.py @@ -35,10 +35,16 @@ class TileScheduler: 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=tile.get_intervalInSeconds(), - next_run_time=datetime.now()) + seconds=seconds, + next_run_time=nextRunTime) self.__jobs[fullName] = job self.__cache[fullName] = None -- GitLab