updater: implementazione iniziale ricerca periodica

This commit is contained in:
marco
2020-01-04 00:31:33 +01:00
parent d1b5b83464
commit 18ee76903e
4 changed files with 28 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
import os
import sys
from threading import Thread
import xbmc
from platformcode import config, logger
@@ -14,6 +15,9 @@ logger.info("init...")
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
sys.path.insert(0, librerias)
if not config.dev_mode():
from platformcode import updater
Thread(target=updater.timer())
from platformcode import launcher

View File

@@ -46,7 +46,7 @@ def loadCommits(page=1):
return ret
def check_addon_init():
def check():
if not addon.getSetting('addon_update_enabled'):
return False
logger.info('Cerco aggiornamenti..')
@@ -166,6 +166,27 @@ def check_addon_init():
return updated
def timer():
import time
curTime = time.time()
file = "special://profile/addon_data/plugin.video.kod/updater_last_check.txt"
period = 10
checked = False
try:
with open(xbmc.translatePath(file), 'r') as fileC:
lastCheck = float(fileC.read())
if curTime - lastCheck > period:
check()
checked = True
except:
check()
checked = True
if checked:
with open(xbmc.translatePath(file), 'w') as fileC:
fileC.write(str(curTime))
def calcCurrHash():
treeHash = githash.tree_hash(addonDir).hexdigest()
logger.info('tree hash: ' + treeHash)

View File

@@ -344,7 +344,7 @@ def check_quickfixes(item):
if not config.dev_mode():
from platformcode import updater
return updater.check_addon_init()
return updater.check()
else:
return False

View File

@@ -5,7 +5,6 @@
import datetime, imp, math, threading, traceback, sys, glob
import channelselector
from platformcode import config
try:
import xbmc, os
@@ -23,7 +22,6 @@ from core import channeltools, filetools, videolibrarytools
from platformcode import logger
from platformcode import platformtools
from specials import videolibrary
from lib import generictools
def update(path, p_dialog, i, t, serie, overwrite):
@@ -380,7 +378,7 @@ if __name__ == "__main__":
# Verificar quick-fixes al abrirse Kodi, y dejarlo corriendo como Thread
if not config.dev_mode():
from platformcode import updater
updater.check_addon_init()
updater.check()
# Copia Custom code a las carpetas de Alfa desde la zona de Userdata
from platformcode import custom_code