-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.py
32 lines (28 loc) · 972 Bytes
/
timer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os, time
from lib import Config
def check_timers(config):
'''Will check every timer setup for it's usage and limits'''
for timer in config.timers:
# restore timers after interval
if timer.usage.isOffInterval():
print('Timer %s is off interval' % timer.name)
timer.usage.release()
if not timer.isRunning():
continue
print('Timer %s is running' % timer.name)
# check for off limit apps
if timer.usage.isOffLimit():
print('Timer %s is off limit' % timer.name)
timer.block()
# increment running apps timer
timer.usage.increment(config.checkInterval)
config = Config()
while True:
# check config changes
if config.hasChanges():
print('Config has changes')
config.reload()
# check app timers
check_timers(config)
# wait interval in minutes
time.sleep(-time.time() % (config.checkInterval * 60))