|
|
@ -1,4 +1,8 @@
|
|
|
|
import subprocess, json, psutil, time, os, win32security, sys, base64, logging, ctypes, copy #Get input argument
|
|
|
|
import subprocess, json, psutil, time, os, win32security, sys, base64, logging, ctypes, copy #Get input argument
|
|
|
|
|
|
|
|
import pickle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from partd import Server
|
|
|
|
|
|
|
|
|
|
|
|
from . import Server
|
|
|
|
from . import Server
|
|
|
|
from . import Timer
|
|
|
|
from . import Timer
|
|
|
|
from . import Processor
|
|
|
|
from . import Processor
|
|
|
@ -323,19 +327,30 @@ def OrchestratorRestart(inGSettings=None):
|
|
|
|
|
|
|
|
|
|
|
|
def OrchestratorSessionSave(inGSettings=None):
|
|
|
|
def OrchestratorSessionSave(inGSettings=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Orchestrator session save in file _SessionLast_RDPList.json (encoding = "utf-8")
|
|
|
|
Orchestrator session save in file
|
|
|
|
|
|
|
|
_SessionLast_RDPList.json (encoding = "utf-8")
|
|
|
|
|
|
|
|
_SessionLast_StorageDict.pickle (binary)
|
|
|
|
|
|
|
|
|
|
|
|
:param inGSettings: Global settings dict (singleton)
|
|
|
|
:param inGSettings: Global settings dict (singleton)
|
|
|
|
:return: True every time
|
|
|
|
:return: True every time
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# Dump RDP List in file json
|
|
|
|
lL = inGSettings["Logger"]
|
|
|
|
lFile = open("_SessionLast_RDPList.json", "w", encoding="utf-8")
|
|
|
|
try:
|
|
|
|
lFile.write(json.dumps(inGSettings["RobotRDPActive"]["RDPList"])) # dump json to file
|
|
|
|
# Dump RDP List in file json
|
|
|
|
lFile.close() # Close the file
|
|
|
|
lFile = open("_SessionLast_RDPList.json", "w", encoding="utf-8")
|
|
|
|
if inGSettings is not None:
|
|
|
|
lFile.write(json.dumps(inGSettings["RobotRDPActive"]["RDPList"])) # dump json to file
|
|
|
|
lL = inGSettings["Logger"]
|
|
|
|
lFile.close() # Close the file
|
|
|
|
if lL: lL.info(
|
|
|
|
if inGSettings is not None:
|
|
|
|
f"Orchestrator has dump the RDP list before the restart.")
|
|
|
|
if lL: lL.info(
|
|
|
|
|
|
|
|
f"Orchestrator has dump the RDP list before the restart.")
|
|
|
|
|
|
|
|
# _SessionLast_StorageDict.pickle (binary)
|
|
|
|
|
|
|
|
if "StorageDict" in inGSettings:
|
|
|
|
|
|
|
|
with open('_SessionLast_StorageDict.pickle', 'wb') as lFile:
|
|
|
|
|
|
|
|
pickle.dump(inGSettings["StorageDict"], lFile)
|
|
|
|
|
|
|
|
if lL: lL.info(
|
|
|
|
|
|
|
|
f"Orchestrator has dump the StorageDict before the restart.")
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
if lL: lL.exception(f"Exception when dump data before restart the Orchestrator")
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def UACKeyListCheck(inRequest, inRoleKeyList) -> bool:
|
|
|
|
def UACKeyListCheck(inRequest, inRoleKeyList) -> bool:
|
|
|
@ -1872,6 +1887,16 @@ def Orchestrator(inGSettings):
|
|
|
|
gSettingsDict["RobotRDPActive"]["RDPList"]=lSessionLastRDPList # Set the last session dict
|
|
|
|
gSettingsDict["RobotRDPActive"]["RDPList"]=lSessionLastRDPList # Set the last session dict
|
|
|
|
if lL: lL.warning(f"RDP Session List was restored from previous Orchestrator session")
|
|
|
|
if lL: lL.warning(f"RDP Session List was restored from previous Orchestrator session")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# _SessionLast_StorageDict.pickle (binary)
|
|
|
|
|
|
|
|
if os.path.exists("_SessionLast_StorageDict.pickle"):
|
|
|
|
|
|
|
|
if "StorageDict" not in inGSettings:
|
|
|
|
|
|
|
|
inGSettings["StorageDict"] = {}
|
|
|
|
|
|
|
|
with open('_SessionLast_StorageDict.pickle', 'rb') as lFile:
|
|
|
|
|
|
|
|
lStorageDictDumpDict = pickle.load(lFile)
|
|
|
|
|
|
|
|
Server.__ComplexDictMerge2to1Overwrite__(in1Dict=inGSettings["StorageDict"], in2Dict=lStorageDictDumpDict) # Merge dict 2 into dict 1
|
|
|
|
|
|
|
|
if lL: lL.warning(f"StorageDict was restored from previous Orchestrator session")
|
|
|
|
|
|
|
|
os.remove("_SessionLast_StorageDict.pickle") # remove the temp file
|
|
|
|
|
|
|
|
|
|
|
|
# Init SettingsUpdate defs from file list (after RDP restore)
|
|
|
|
# Init SettingsUpdate defs from file list (after RDP restore)
|
|
|
|
lSettingsUpdateFilePathList = gSettingsDict.get("OrchestratorStart", {}).get("DefSettingsUpdatePathList",[])
|
|
|
|
lSettingsUpdateFilePathList = gSettingsDict.get("OrchestratorStart", {}).get("DefSettingsUpdatePathList",[])
|
|
|
|
lSubmoduleFunctionName = "SettingsUpdate"
|
|
|
|
lSubmoduleFunctionName = "SettingsUpdate"
|
|
|
|