From ba084abdeb2d5f8fbf35120acba67963ddf47c83 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 8 Jul 2019 16:27:27 +0200 Subject: [PATCH] Update updater.py --- src/launcher/updater.py | 55 +++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/src/launcher/updater.py b/src/launcher/updater.py index ff5c3d2..39a6ee1 100644 --- a/src/launcher/updater.py +++ b/src/launcher/updater.py @@ -22,12 +22,17 @@ * along with CNIRevelator. If not, see . * ******************************************************************************** """ -from globs import logfile -from win32com.client import Dispatch +from win32com.client import Dispatch +import traceback +import sys +import time + +import logger # logger.py import globs # globs.py - -def createShortcut(path, target='', wDir='', icon=''): +import ihm # ihm.py + +def createShortcut(path, target='', wDir='', icon=''): ext = path[-3:] if ext == 'url': shortcut = file(path, 'w') @@ -44,7 +49,43 @@ def createShortcut(path, target='', wDir='', icon=''): else: shortcut.IconLocation = icon shortcut.save() - + +## Main Batch Function +def batch(): + + # Global Handlers + logfile = logger.logCur + launcherWindow = ihm.launcherWindowCur + + for i in range(0,10000): + if i % 1000 : launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('Starting... ' + str(i))) + return + +## Main Function def umain(): - for i in range(0,155555555555555): - print(i) \ No newline at end of file + try: + # Global Handlers + logfile = logger.logCur + launcherWindow = ihm.launcherWindowCur + + try: + batch() + except Exception as e: + logfile.printerr("An error occured on the thread : " + str(traceback.format_exc())) + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('ERROR : ' + str(e))) + time.sleep(3) + launcherWindow.destroy() + return 1 + + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text='Software is up-to-date !') + time.sleep(2) + launcherWindow.destroy() + return 0 + + except: + logfile.printerr("A FATAL ERROR OCCURED : " + str(traceback.format_exc())) + launcherWindow.destroy() + sys.exit(2) + return 2 + +