def run(user): # Initialisation des Parametres + Variables _OPERATION = "Synchronisation des Marchés" logger.info( "Lancement de la Synchronisation des Marchés par : {}".format( user)) SyncMarketsHelpersObj = None try: # ======================================================================================== yield Render.sseTemplate( perc=1, message="Demarrage de la synchronisation des Marchés", operation=_OPERATION, categorie="NORMAL") SyncMarketsHelpersObj = SyncMarketsHelpers() # Initialisation du Broker yield Render.sseTemplate(perc=25, message="Connexion au Broker", operation=_OPERATION, categorie="TITLE") SyncMarketsHelpersObj.connect() # Obtenir les Marchés yield Render.sseTemplate(perc=50, message="Recuperation des Marchés", operation=_OPERATION, categorie="TITLE") SyncMarketsHelpersObj.getMarkets() # Mise à jour dela BDD yield Render.sseTemplate( perc=75, message="Mise à jour de la BDD (Traitement Long)", operation=_OPERATION, categorie="TITLE") SyncMarketsHelpersObj.updateBdd() # Fin de Traitement SyncMarketsHelpersObj.disconnect() yield Render.sseTemplate( perc=100, message="Fin de Syncronisation des Ordres", operation=_OPERATION, categorie="SUCCESS") except Exception as error: logger.exception(error) yield Render.sseTemplate(perc=100, message=str(error), operation=_OPERATION, categorie="ERROR") finally: time.sleep(0.2)
def run(pid, user): try: x = 0 while x <= 100: yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="TITLE") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="NORMAL") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="NORMAL") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="NORMAL") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="NORMAL") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="INFO") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="ERROR") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="SUCCESS") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="WARNING") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="DEFAULT") yield Render.sseTemplate(perc=x, message="TESTTASK" + str(x), operation=_OPERATION, categorie="ERROR_TASK") yield Render.sseTemplate(perc=x, message="TESTTASK" + str(x), operation=_OPERATION, categorie="SUCCESS_TASK") yield Render.sseTemplate(perc=x, message="TEST" + str(x), operation=_OPERATION, categorie="WARNING") x = x + 75 # if x == 75: # raise Exception("NOOOOOOOOOOOOOOOOOOOOOONNNNNNNNNNNNNNNNN") yield Render.sseTemplate(perc=100, message="Fin de traitement", operation="WOO HOO", categorie="SUCCESS") except Exception as error: logger.pid = pid logger.user = user logger.error( '{APP_NAME} à rencontré une erreur (TRAITEMENT)'.format( APP_NAME=cfg._APP_NAME)) logger.critical() yield Render.sseTemplate(perc=100, message=str(error), operation=_OPERATION, categorie="ERROR") finally: time.sleep(0.2)