From 921f8f72a2782bd2cb8b8923236263d087b05ab8 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Fri, 13 Nov 2020 19:28:57 +0300 Subject: [PATCH] # Add version check + autorefresh if version was changed (with backward compatibility) --- Orchestrator/Settings/CP_VersionCheck.py | 29 +++++++++++++++++++ .../Orchestrator/BackwardCompatibility.py | 5 +++- .../pyOpenRPA/Orchestrator/Orchestrator.py | 2 ++ .../pyOpenRPA/Orchestrator/ServerSettings.py | 3 ++ .../Orchestrator/SettingsTemplate.py | 1 + Sources/pyOpenRPA/Orchestrator/Web/Index.js | 13 +++++++-- changelog.md | 3 ++ 7 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 Orchestrator/Settings/CP_VersionCheck.py diff --git a/Orchestrator/Settings/CP_VersionCheck.py b/Orchestrator/Settings/CP_VersionCheck.py new file mode 100644 index 00000000..72998c7b --- /dev/null +++ b/Orchestrator/Settings/CP_VersionCheck.py @@ -0,0 +1,29 @@ +import psutil, datetime, logging, os, json + +# !ATTENTION - Current Control panel works only from pyOpenRPA v1.2.0! + +def ControlPanelRenderDict(inGSettings): + + lResultDict={ + "HeaderLeftText":"Version check", + "HeaderRightText":"Orchestrator", + "DataStorageKey":"", #Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side + "SubheaderText":"", + "BodyKeyValueList":[ + {"Key": "Client", "Value": '
'}, + {"Key": "Server", "Value": inGSettings["VersionStr"]}, + ], + "FooterText":"", + "FooterButtonX2List":[], + "FooterButtonX1List":[], + "GlobalStorage": "" # UNCOMMENT FOR DEBUG PURPOSE TO WATCH inGSettings on client side + } + return lResultDict +# Check in control panel, that process is runnning + +#Orchestrator settings +def SettingsUpdate(inGSettings): + #Add RobotRDPActive in control panel + inGSettings["ControlPanelDict"]["RobotList"].append({"RenderFunction": ControlPanelRenderDict, "KeyStr": "VersionCheck"}) + + return inGSettings \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py b/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py index c162c38c..a60aa1f7 100644 --- a/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py +++ b/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py @@ -175,4 +175,7 @@ def Update(inGSettings): "ExecuteBool": True, # Flag to execute thread processor "ThreadIdInt": None # Fill thread id when processor will be inited } - if lL: lL.warning(f"Backward compatibility (v1.1.20 to v1.2.0): Create new structure 'ProcessorDict'") # Log about compatibility \ No newline at end of file + if lL: lL.warning(f"Backward compatibility (v1.1.20 to v1.2.0): Create new structure 'ProcessorDict'") # Log about compatibility + if "VersionStr" not in inGSettings: # Create new ProcessorDict structure + inGSettings["VersionStr"] = None + if lL: lL.warning(f"Backward compatibility (v1.1.20 to v1.2.0): Create new attribute 'VersionStr'") # Log about compatibility \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/Orchestrator.py b/Sources/pyOpenRPA/Orchestrator/Orchestrator.py index 7f29a46f..a7527947 100644 --- a/Sources/pyOpenRPA/Orchestrator/Orchestrator.py +++ b/Sources/pyOpenRPA/Orchestrator/Orchestrator.py @@ -500,10 +500,12 @@ def GSettingsAutocleaner(inGSettings): inGSettings["Client"]["Session"]["TechnicalSessionGUIDCache"] = lTechnicalSessionGUIDCacheNew # Set updated Cache # # # # # # # # # # # # # # # # # # # # # # # # # # +from .. import __version__ # Get version from the package # Main def for orchestrator def Orchestrator(inGSettings): #mGlobalDict = Settings.Settings(sys.argv[1]) gSettingsDict = inGSettings # Alias for old name in alg + inGSettings["VersionStr"] = __version__ #Logger alias lL = gSettingsDict["Logger"] if lL: lL.info("Link the gSettings in submodules") #Logging diff --git a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py index 0f0693d9..b5bb7601 100644 --- a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py +++ b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py @@ -73,6 +73,9 @@ def Monitor_ControlPanelDictGet_SessionCheckInit(inRequest,inGlobalDict): # step 1 - get cookie SessionGUIDStr lSessionGUIDStr = inRequest.headers.get("SessionGUIDStr", None) if lSessionGUIDStr is not None: # Check if GUID session is ok + #inRequest.OpenRPAResponseDict["StatusCode"] = 301 + #inRequest.OpenRPAResponseDict["Headers"]["Location"] = "/" + #if lL: lL.info(f"GUID is detected - send HTTP 301 to refresh page") lCookieSessionGUIDStr = lSessionGUIDStr # Get the existing GUID if lSessionGUIDStr not in inGlobalDict["Client"]["Session"]["TechnicalSessionGUIDCache"]: lCookieSessionGUIDStr= TechnicalSessionNew(inSessionGUIDStr = lSessionGUIDStr) # Create new session diff --git a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py index ee608416..0b88f61d 100644 --- a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py +++ b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py @@ -3,6 +3,7 @@ import os, logging, datetime, sys # Technical def - return GSettings structure with examples def __Create__(): return { + "VersionStr": None, # Will be filled in orchestrator, "Autocleaner": { # Some gurbage is collecting in g settings. So you can configure autocleaner to periodically clear gSettings "IntervalSecFloat": 600.0, # Sec float to periodically clear gsettings diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Index.js b/Sources/pyOpenRPA/Orchestrator/Web/Index.js index 17d52f94..b90cd74d 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Index.js +++ b/Sources/pyOpenRPA/Orchestrator/Web/Index.js @@ -221,7 +221,7 @@ $(document).ready(function() { } //inHostURI: http://localhost:8081 mGlobal.Monitor.ScreenshotModal.Show=function(inHostURI=" ") { - $('.ui.modal.daemon-screenshot').modal('show'); + $('.ui.modal.daemon-screenshot').modal({'onHide':function (inElement) {mGlobal.Monitor.ScreenshotModal.Close();} }).modal('show'); //Функция обновления картинки lScreenshotUpdate=function() { @@ -369,7 +369,6 @@ $(document).ready(function() { } //mGlobal.Monitor.fControlPanelRefresh() // recursive } - mGlobal.Monitor.fControlPanelRefresh() mGlobal.Test=function() { ///Обнулить таблицу lData = [ @@ -684,7 +683,11 @@ $(document).ready(function() { { "Type": "GlobalDictKeyListValueGet", "KeyList": ["Server","WorkingDirectoryPathStr"] - } + }, + { + "Type": "GlobalDictKeyListValueGet", + "KeyList": ["VersionStr"] + }, ] $.ajax({ type: "POST", @@ -696,9 +699,13 @@ $(document).ready(function() { var lUACAsk = mGlobal.UserRoleAsk // Alias var lResponseList=JSON.parse(lData) mGlobal.WorkingDirectoryPathStr = lResponseList[0]["Result"] + mGlobal.VersionStr = lResponseList[1]["Result"] }, dataType: "text" }); } + + //Main sub mGlobal.OrchestratorModelUpdate() // Cal the update orchestrator model + mGlobal.Monitor.fControlPanelRefresh() }); \ No newline at end of file diff --git a/changelog.md b/changelog.md index a7e37758..3c7dee7b 100644 --- a/changelog.md +++ b/changelog.md @@ -22,6 +22,9 @@ - - def PythonStart(inModulePathStr, inDefNameStr, inArgList=[], inArgDict={}, inLogger = None): # Python import module and start def - - Add pyOpenRPA.Orchestrator.Core module technical defs - - - def IsProcessorThread() return True or False +- Orchestrator WEB fix: Don't request screenshot if no modal is active in front +- Add Version field in Orchestrator back + front +- Add front autorefresh if front/back pyOpenRPA versions are differs (see CP_VersionCheck.py) [1.1.0] After 2 month test prefinal with new improovements (+RobotRDPActive in Orchestrator + Easy ControlPanelTemplate) Beta before 1.1.0 (new way of OpenRPA with improvements. Sorry, but no backward compatibility)/ Backward compatibility will start from 1.0.1