1
0
mirror of https://gitlab.os-k.eu/neox/CNIRevelator.git synced 2023-08-25 14:03:10 +02:00

Added temporization on update to prevent updating every launch

This commit is contained in:
Adrien Bourmault 2019-08-26 16:50:51 +02:00 committed by GitHub
parent 6d4104e6fa
commit 30e1b15dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 27 deletions

View File

@ -31,22 +31,6 @@ version = [3, 1, 4]
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
verstring = "{}.{}".format(version[0], version[1])
CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8'
CNIRFolder = os.getcwd()
CNIRLColor = "#006699"
CNIRName = "CNIRevelator {}".format(verstring)
CNIRCryptoKey = '82Xh!efX3#@P~2eG'
CNIRNewVersion = False
CNIRConfig = CNIRFolder + '\\config\\conf.ig'
CNIRTesser = CNIRFolder + '\\Tesseract-OCR5\\'
CNIRErrLog = CNIRFolder + '\\logs\\error.log'
CNIRMainLog = CNIRFolder + '\\logs\\main.log'
CNIRUrlConfig = CNIRFolder + '\\config\\urlconf.ig'
CNIRVerStock = CNIRFolder + '\\downloads\\versions.lst'
CNIREnv = CNIRFolder + '\\Data\\'
CNIRTesserHash = '947224361ffab8c01f05c9394b44b1bd7c8c3d4d'
CNIRFolder = os.path.dirname(os.path.realpath(__file__))
CNIRLColor = "#006699"
@ -61,6 +45,7 @@ CNIRTesser = CNIRFolder + '\\Tesseract-OCR5\\'
CNIRErrLog = CNIRFolder + '\\logs\\error.log'
CNIRMainLog = CNIRFolder + '\\logs\\main.log'
CNIRUrlConfig = CNIRFolder + '\\config\\urlconf.ig'
CNIRLastUpdate = CNIRFolder + '\\config\\lastupdate.ig'
CNIRVerStock = CNIRFolder + '\\downloads\\versions.lst'
CNIREnv = CNIRFolder + '\\Data\\'

View File

@ -36,6 +36,7 @@ import zipfile
import hashlib
import subprocess
import psutil
import datetime
import critical # critical.py
import github # github.py
@ -316,17 +317,6 @@ def umain():
# Global Handlers
logfile = logger.logCur
credentials = downloader.newcredentials()
if not credentials.valid:
logfile.printerr("Credentials Error. No effective update !")
launcherWindow.printmsg(lang.all[globs.CNIRlang]["Credentials Error. No effective update !"])
time.sleep(2)
launcherWindow.exit()
return 0
github.credentials = credentials
# Cleaner for the old version if detected
if len(sys.argv) > 2 and str(sys.argv[1]) == "DELETE":
@ -361,6 +351,49 @@ def umain():
globs.CNIROpenFile = True
logfile.printdbg("Command line received : {}".format(sys.argv))
credentials = downloader.newcredentials()
if not credentials.valid:
logfile.printerr("Credentials Error. No effective update !")
launcherWindow.printmsg(lang.all[globs.CNIRlang]["Credentials Error. No effective update !"])
time.sleep(2)
launcherWindow.exit()
return 0
github.credentials = credentials
# Check if update is needed
currentDate = datetime.datetime.now()
if os.path.isfile(globs.CNIRLastUpdate):
with open(globs.CNIRLastUpdate, 'r') as (configFile):
try:
# Reading it
lastUpdate = datetime.datetime.strptime(configFile.read(),"%d/%m/%Y")
except Exception as e:
critical.crashCNIR()
raise IOError(str(e))
else:
# Recreating the url file
lastUpdate = currentDate
try:
os.mkdir(globs.CNIRFolder + '\\config')
except:
pass
with open(globs.CNIRLastUpdate, 'w') as (configFile):
try:
# Writing it
configFile.write("{}/{}/{}".format(currentDate.day, currentDate.month, currentDate.year))
except Exception as e:
critical.crashCNIR()
raise IOError(str(e))
if (currentDate - lastUpdate).min !=0 and (currentDate - lastUpdate).days < 7:
launcherWindow.exit()
return 0
# Update batch
try:
try:
# EXECUTING THE UPDATE BATCH