-
Notifications
You must be signed in to change notification settings - Fork 3
/
service.py
38 lines (31 loc) · 922 Bytes
/
service.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
33
34
35
36
37
38
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
script.skin.helper.widgets
Main service entry point
"""
from resources.lib.utils import log_msg, ADDON_ID
from resources.lib.kodi_monitor import KodiMonitor
import xbmc
import xbmcgui
import xbmcaddon
import time
TASK_INTERVAL = 520
WIN = xbmcgui.Window(10000)
ADDON = xbmcaddon.Addon(ADDON_ID)
MONITOR = KodiMonitor(win=WIN, addon=ADDON)
log_msg('Backgroundservice started', xbmc.LOGNOTICE)
# keep the kodi monitor alive which processes database updates to refresh widgets
while not MONITOR.abortRequested():
# set generic widget reload
if TASK_INTERVAL >= 300:
WIN.setProperty("widgetreload2", time.strftime("%Y%m%d%H%M%S", time.gmtime()))
TASK_INTERVAL = 0
else:
TASK_INTERVAL += 10
# sleep for 10 seconds
MONITOR.waitForAbort(10)
del MONITOR
del WIN
del ADDON
log_msg('Backgroundservice stopped', xbmc.LOGNOTICE)