Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit faf38ae

Browse files
committed
Add spec for stale file check, in regards to issue #2
1 parent 4cba603 commit faf38ae

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,25 @@ Make sure to fill in all the fields in [config.json](config.json.example).
8282
- `"length"`: integer; length of the digital photo frame display, in pixels
8383
- `"destination"`: string; must be a valid path (relative or absolute) that can be parsed by `pathlib.Path`
8484

85-
Optional configuration:
85+
### Optional configuration
86+
87+
**Quiet Hours**
8688

8789
- `"quiet_start"`: integer; when quiet hours should start; requests (except for `GET` `QuietHours`) will not be fulfilled during this time
8890
- `"quiet_end"`: integer; when quiet hours should end; requests will resume
8991

9092
⚠ If you intend to use quiet hours, both quiet hours fields must be defined and not also be the same as each other. You cannot define only one field.
9193

94+
**Stale File Check**
95+
96+
- `"stale_check"`: boolean; whether to enable stale file checking (default: `false`)
97+
- `"stale_threshold"`: integer; how long time in hours must pass since the last file update (default: `0`)
98+
- `"stale_follow_quiet_hours"`: boolean; whether quiet hours should affect the check (see note below) (default: `false`)
99+
100+
⚠ If you intend to use the stale file check, both `"stale_check"` and `stale_threshold"` must be set and not their respective default values.
101+
102+
⚠ If `"stale_follow_quiet_hours"` is set to `true`, the file check will subtly change: it will no longer run when quiet hours are in effect, and the threshold will subtract the quiet hours that have elapsed since the last file update.
103+
92104
## Disclaimer
93105

94106
This project is not affiliated with or endorsed by [Leed's] or [the Raspberry Pi Foundation][RPI]. See [LICENSE](LICENSE) for more detail.

config.json.example

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"length": 234,
44
"destination": "/path/to/destination",
55
"quiet_start": 21,
6-
"quiet_end": 7
6+
"quiet_end": 7,
7+
"stale_check": false,
8+
"stale_threshold": 0,
9+
"stale_follow_quiet_hours": false
710
}

photo_dash/config.py

+23
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,27 @@
7878
except (KeyError, ValueError):
7979
LOGGER.info('Quiet hours are disabled.')
8080
LOGGER.info('They may have been malformed or missing.')
81+
LOGGER.info('To enable quiet hours, make sure both fields are filled in')
82+
LOGGER.info('and both values should not be the same.')
8183
QUIET_HOURS = None
84+
85+
86+
try:
87+
STALE_CHECK = CONFIG['stale_check']
88+
STALE_THRESHOLD = CONFIG['stale_threshold']
89+
if type(STALE_THRESHOLD) is not int or STALE_THRESHOLD < 1:
90+
raise ValueError
91+
try:
92+
STALE_FOLLOW_QUIET_HOURS = CONFIG['stale_follow_quiet_hours']
93+
except KeyError:
94+
LOGGER.info('Quiet hours check in stale file check was not set, so')
95+
LOGGER.info('quiet hours will not be checked in stale file check.')
96+
STALE_FOLLOW_QUIET_HOURS = False
97+
except KeyError:
98+
LOGGER.info('Stale file check is disabled.')
99+
LOGGER.info('To enable stale file check, make sure stale_check is `true`')
100+
LOGGER.info('and `stale_threshold` isn\'t 0.')
101+
STALE_CHECK = False
102+
except ValueError:
103+
LOGGER.info('Stale file check is disabled.')
104+
LOGGER.info('Set `stale_threshold` a number above 0.')

0 commit comments

Comments
 (0)