From f618515fc270653c808a95a2218df7ec979a3466 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Tue, 15 Dec 2020 17:53:55 +0300 Subject: [PATCH] Fix Logging BUG with WEB dump --- .../Orchestrator/BackwardCompatibility.py | 5 ++++- .../pyOpenRPA/Orchestrator/SettingsTemplate.py | 14 +++++++------- .../pyOpenRPA/Orchestrator/__Orchestrator__.py | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py b/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py index be5198ca..e06cb1c1 100644 --- a/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py +++ b/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py @@ -382,7 +382,10 @@ def Update(inGSettings): lItemDict = lRuleDomainUserDeepCopyDict[lItemKeyTurple] if "ControlPanelKeyAllowedList" in lItemDict: lShowWarnBool = True - lUACClientDict = {"pyOpenRPADict":{"CPKeyDict":{}}} + if len(lItemDict["ControlPanelKeyAllowedList"])>0: + lUACClientDict = {"pyOpenRPADict": {"CPKeyDict": {}}} + else: + lUACClientDict = {} for lAllowedKeyItemStr in lItemDict["ControlPanelKeyAllowedList"]: lUACClientDict["pyOpenRPADict"]["CPKeyDict"][lAllowedKeyItemStr]=True # Convert # Send update UACDict for user by the list diff --git a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py index 9a35c437..d0279eb4 100644 --- a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py +++ b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py @@ -337,11 +337,11 @@ def Create(inModeStr="BASIC"): handler.setFormatter(mRobotLoggerFormatter) mRobotLogger.addHandler(handler) ############################################ - mHandlerDumpLogList = LoggerHandlerDumpLogList.LoggerHandlerDumpLogList(inDict=lResult["Client"], - inKeyStr="DumpLogList", - inHashKeyStr="DumpLogListHashStr", - inRowCountInt=lResult["Client"][ - "DumpLogListCountInt"]) - mHandlerDumpLogList.setFormatter(mRobotLoggerFormatter) - mRobotLogger.addHandler(mHandlerDumpLogList) + #mHandlerDumpLogList = LoggerHandlerDumpLogList.LoggerHandlerDumpLogList(inDict=lResult["Client"], + # inKeyStr="DumpLogList", + # inHashKeyStr="DumpLogListHashStr", + # inRowCountInt=lResult["Client"][ + # "DumpLogListCountInt"]) + #mHandlerDumpLogList.setFormatter(mRobotLoggerFormatter) + #mRobotLogger.addHandler(mHandlerDumpLogList) return lResult # return the result dict \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index 50d16f2a..217e5c4c 100644 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -1,9 +1,10 @@ -import subprocess, json, psutil, time, os, win32security, sys, base64 #Get input argument +import subprocess, json, psutil, time, os, win32security, sys, base64, logging #Get input argument from . import Server from . import Timer from . import Processor from . import BackwardCompatibility # Backward compatibility from v1.1.13 from . import Core +from .Utils import LoggerHandlerDumpLogList # ATTENTION! HERE IS NO Relative import because it will be imported dynamically # All function check the flag SessionIsWindowResponsibleBool == True else no cammand is processed @@ -844,6 +845,20 @@ def Orchestrator(inGSettings): # Turn on backward compatibility BackwardCompatibility.Update(inGSettings= gSettingsDict) + # Init the log dump to WEB + #import pdb; pdb.set_trace() + ############################################ + if len(lL.handlers)== 0: + mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') + else: + mRobotLoggerFormatter = lL.handlers[0].formatter + mHandlerDumpLogList = LoggerHandlerDumpLogList.LoggerHandlerDumpLogList(inDict=inGSettings["Client"], + inKeyStr="DumpLogList", + inHashKeyStr="DumpLogListHashStr", + inRowCountInt=inGSettings["Client"]["DumpLogListCountInt"]) + mHandlerDumpLogList.setFormatter(mRobotLoggerFormatter) + lL.addHandler(mHandlerDumpLogList) + # Append Orchestrator def to ProcessorDictAlias lModule = sys.modules[__name__] lModuleDefList = dir(lModule)