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:
parent
6d4104e6fa
commit
30e1b15dd1
17
src/globs.py
17
src/globs.py
@ -31,22 +31,6 @@ version = [3, 1, 4]
|
|||||||
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
|
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
|
||||||
verstring = "{}.{}".format(version[0], version[1])
|
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'
|
CNIRTesserHash = '947224361ffab8c01f05c9394b44b1bd7c8c3d4d'
|
||||||
CNIRFolder = os.path.dirname(os.path.realpath(__file__))
|
CNIRFolder = os.path.dirname(os.path.realpath(__file__))
|
||||||
CNIRLColor = "#006699"
|
CNIRLColor = "#006699"
|
||||||
@ -61,6 +45,7 @@ CNIRTesser = CNIRFolder + '\\Tesseract-OCR5\\'
|
|||||||
CNIRErrLog = CNIRFolder + '\\logs\\error.log'
|
CNIRErrLog = CNIRFolder + '\\logs\\error.log'
|
||||||
CNIRMainLog = CNIRFolder + '\\logs\\main.log'
|
CNIRMainLog = CNIRFolder + '\\logs\\main.log'
|
||||||
CNIRUrlConfig = CNIRFolder + '\\config\\urlconf.ig'
|
CNIRUrlConfig = CNIRFolder + '\\config\\urlconf.ig'
|
||||||
|
CNIRLastUpdate = CNIRFolder + '\\config\\lastupdate.ig'
|
||||||
CNIRVerStock = CNIRFolder + '\\downloads\\versions.lst'
|
CNIRVerStock = CNIRFolder + '\\downloads\\versions.lst'
|
||||||
CNIREnv = CNIRFolder + '\\Data\\'
|
CNIREnv = CNIRFolder + '\\Data\\'
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import zipfile
|
|||||||
import hashlib
|
import hashlib
|
||||||
import subprocess
|
import subprocess
|
||||||
import psutil
|
import psutil
|
||||||
|
import datetime
|
||||||
|
|
||||||
import critical # critical.py
|
import critical # critical.py
|
||||||
import github # github.py
|
import github # github.py
|
||||||
@ -317,17 +318,6 @@ def umain():
|
|||||||
# Global Handlers
|
# Global Handlers
|
||||||
logfile = logger.logCur
|
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
|
# Cleaner for the old version if detected
|
||||||
if len(sys.argv) > 2 and str(sys.argv[1]) == "DELETE":
|
if len(sys.argv) > 2 and str(sys.argv[1]) == "DELETE":
|
||||||
globs.CNIRNewVersion = True
|
globs.CNIRNewVersion = True
|
||||||
@ -361,6 +351,49 @@ def umain():
|
|||||||
globs.CNIROpenFile = True
|
globs.CNIROpenFile = True
|
||||||
logfile.printdbg("Command line received : {}".format(sys.argv))
|
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:
|
||||||
try:
|
try:
|
||||||
# EXECUTING THE UPDATE BATCH
|
# EXECUTING THE UPDATE BATCH
|
||||||
|
Loading…
Reference in New Issue
Block a user