# Add version check + autorefresh if version was changed (with backward compatibility)

dev-linux
Ivan Maslov 4 years ago
parent 178ba3398d
commit 921f8f72a2

@ -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":"<script>if (!('VersionStr' in mGlobal)) {window.location.reload(true);} else { if (mGlobal.VersionStr != '"+inGSettings["VersionStr"]+"') { window.location.reload(true);} else { $('div.orchestrator-version').html(mGlobal['VersionStr']);}}</script>",
"BodyKeyValueList":[
{"Key": "Client", "Value": '<div class="orchestrator-version" style="display:inline;"></div>'},
{"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

@ -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
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

@ -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

@ -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

@ -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

@ -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()
});

@ -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

Loading…
Cancel
Save