CNIRevelator/src/CNIRevelator.py

84 lines
3.4 KiB
Python
Raw Normal View History

2019-07-09 16:13:16 +02:00
"""
********************************************************************************
* CNIRevelator *
* *
* Desc: Application launcher & updater *
* *
* Copyright © 2018-2019 Adrien Bourmault (neox95) *
* *
* This file is part of CNIRevelator. *
* *
* CNIRevelator is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* any later version. *
* *
* CNIRevelator is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY*without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with CNIRevelator. If not, see <https:*www.gnu.org/licenses/>. *
********************************************************************************
"""
2019-07-09 23:01:09 +02:00
import sys
import os
import subprocess
import threading
import traceback
2019-07-09 16:13:16 +02:00
2019-07-09 23:01:09 +02:00
import launcher # launcher.py
import ihm # ihm.py
import logger # logger.py
import updater # updater.py
2019-07-10 16:50:40 +02:00
import globs # globs.py
2019-07-09 16:13:16 +02:00
2019-07-09 23:01:09 +02:00
## MAIN FUNCTION OF CNIREVELATOR
2019-07-10 00:20:39 +02:00
def main():
2019-07-10 10:12:54 +02:00
2019-07-09 16:13:16 +02:00
import CNI_pytesseract as pytesseract
try:
os.environ['PATH'] = CST_FOLDER + 'Tesseract-OCR4\\'
os.environ['TESSDATA_PREFIX'] = CST_FOLDER + 'Tesseract-OCR4\\tessdata'
tesser_version = pytesseract.get_tesseract_version()
except Exception as e:
logger.error('main() : **** ERROR WITH TESSERACT MODULE ' + str(e) + ' ****')
else:
text = 'Tesseract version ' + str(tesser_version) + ' Licensed Apache 2004 successfully initiated\n'
main_w.montext(text)
main_w.montext('\n\nEntrez la première ligne de MRZ svp \n')
2019-07-10 10:12:54 +02:00
2019-07-09 16:13:16 +02:00
if CST_CHANGELOG.isOn:
showinfo('Changelog : résumé de mise à jour', ('Version du logiciel : ' + CST_VER + ' ' + CST_TYPE + ' Revision ' + CST_REV + '\n\n' + CST_CHANGELOG.text), parent=main_w)
logger.info('main() : **** Launching App_main() ****')
main_w.mainloop()
logger.info('main() : **** Ending App_main() ****')
2019-07-09 23:01:09 +02:00
## BOOTSTRAP OF CNIREVELATOR
2019-07-09 16:13:16 +02:00
try:
2019-07-09 23:01:09 +02:00
launcherThread = threading.Thread(target=updater.umain, daemon=False)
launcher.lmain(launcherThread)
except Exception:
sys.exit(1)
2019-07-09 16:13:16 +02:00
2019-07-10 11:47:54 +02:00
if updater.UPDATE_IS_MADE:
2019-07-10 16:50:40 +02:00
# Launch app !
args = updater.UPATH + '\\CNIRevelator.exe ' + globs.CNIRFolder
cd = updater.UPATH
for i in range(0,3):
try:
updater.spawnProcess(args, cd)
except:
time.sleep(3)
continue
break
2019-07-10 11:47:54 +02:00
sys.exit(0)
2019-07-10 23:05:23 +02:00
#main()
2019-07-10 16:50:40 +02:00
sys.exit(0)