|
|
|
@ -1,4 +1,8 @@
|
|
|
|
|
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 Timer
|
|
|
|
|
from . import Processor
|
|
|
|
@ -323,19 +327,30 @@ def OrchestratorRestart(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)
|
|
|
|
|
:return: True every time
|
|
|
|
|
"""
|
|
|
|
|
lL = inGSettings["Logger"]
|
|
|
|
|
try:
|
|
|
|
|
# Dump RDP List in file json
|
|
|
|
|
lFile = open("_SessionLast_RDPList.json", "w", encoding="utf-8")
|
|
|
|
|
lFile.write(json.dumps(inGSettings["RobotRDPActive"]["RDPList"])) # dump json to file
|
|
|
|
|
lFile.close() # Close the file
|
|
|
|
|
if inGSettings is not None:
|
|
|
|
|
lL = inGSettings["Logger"]
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
def UACKeyListCheck(inRequest, inRoleKeyList) -> bool:
|
|
|
|
@ -1872,6 +1887,16 @@ def Orchestrator(inGSettings):
|
|
|
|
|
gSettingsDict["RobotRDPActive"]["RDPList"]=lSessionLastRDPList # Set the last session dict
|
|
|
|
|
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)
|
|
|
|
|
lSettingsUpdateFilePathList = gSettingsDict.get("OrchestratorStart", {}).get("DefSettingsUpdatePathList",[])
|
|
|
|
|
lSubmoduleFunctionName = "SettingsUpdate"
|
|
|
|
|