# Orchestrator RDPActive fixes : add Command ActivityType GlobalDictKeyListValueOperator+ (to merge 2 lists into 1)

Signed-off-by: Ivan Maslov <i.maslov@mail.ru>
dev-linux
Ivan Maslov 4 years ago
parent d50d1d6fde
commit e8f527d927

@ -70,11 +70,11 @@ def ControlPanelRenderDict(inGSettings):
}"""
# START :: Create activities :: START #
## Robot START (create RDP session, send CMD to start process)
lActivityROBOTStartEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStartList)});".replace("\"","\'")
lActivityROBOTStartEscaped = f"mGlobal.Processor.ServerValueOperatorPlus({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStartList)});".replace("\"","\'")
## Robot SAFE STOP (SAFE STOP COMMAND (FROM ROBOT RULES), Logoff must do robot when safe turn off)
lActivityROBOTSafeStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(gOrchestratorToRobotResetSafeStopKeyList)},true);".replace("\"","\'")
lActivityROBOTSafeStopEscaped = f"mGlobal.Processor.ServerValueOperatorPlus({json.dumps(gOrchestratorToRobotResetSafeStopKeyList)},true);".replace("\"","\'")
## Robot FORCE STOP (send CMD to stop process, logoff)
lActivityROBOTStopEscaped = f"mGlobal.Processor.ServerValueSet({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStopList)});".replace("\"","\'")
lActivityROBOTStopEscaped = f"mGlobal.Processor.ServerValueOperatorPlus({json.dumps(['RobotRDPActive','ActivityList'])},{json.dumps(gActivityROBOTStopList)});".replace("\"","\'")
# END :: Create activities :: END #
# START :: Init result dict template :: START #
# lBodyKeyValue_r3_start=f'<a onclick="{lActivityROBOTStartEscaped}" style=\"color:green\">Start</a>'
@ -133,7 +133,7 @@ lActivityTimeItemRobotStart = {
"TimeHH:MM": gActivityROBOTStartTimeHH_MMStr, #Time [HH:MM] to trigger activity
"WeekdayList": gActivityROBOTStartWeekdayList, #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
"Activity":{
"Type": "GlobalDictKeyListValueSet", #Activity type
"Type": "GlobalDictKeyListValueOperator+", #Activity type
"KeyList": ['RobotRDPActive','ActivityList'], # RobotRDP Active ActivityList
"Value": gActivityROBOTStartList # ActivityList - see upper
}
@ -143,7 +143,7 @@ lActivityTimeItemRobotStop = {
"TimeHH:MM": gActivityROBOTStopTimeHH_MMStr, #Time [HH:MM] to trigger activity
"WeekdayList": gActivityROBOTStopWeekdayList, #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
"Activity":{
"Type": "GlobalDictKeyListValueSet", #Activity type
"Type": "GlobalDictKeyListValueOperator+", #Activity type
"KeyList": ['RobotRDPActive','ActivityList'], # RobotRDP Active ActivityList
"Value": gActivityROBOTStopList # ActivityList - see upper
}

@ -34,6 +34,11 @@ import psutil
# "Value": <List, Dict, String, int>
# },
# {
# "Type": "GlobalDictKeyListValueOperator+",
# "KeyList": ["key1","key2",...],
# "Value": <List, Dict, String, int>
# },
# {
# "Type": "GlobalDictKeyListValueGet",
# "KeyList": ["key1","key2",...]
# },
@ -146,6 +151,21 @@ def Activity(inActivity):
lDict[lItem["KeyList"][-1]].append(lItem["Value"])
lItem["Result"] = True
###########################################################
# Обработка команды GlobalDictKeyListValueOperator+
###########################################################
if lItem["Type"] == "GlobalDictKeyListValueOperator+":
lDict = gSettingsDict
for lItem2 in lItem["KeyList"][:-1]:
# Check if key - value exists
if lItem2 in lDict:
pass
else:
lDict[lItem2] = {}
lDict = lDict[lItem2]
# Set value
lDict[lItem["KeyList"][-1]]+=lItem["Value"]
lItem["Result"] = True
###########################################################
#Обработка команды GlobalDictKeyListValueGet
###########################################################
if lItem["Type"]=="GlobalDictKeyListValueGet":

@ -10,6 +10,7 @@ gSettings = None # Gsettings will be initialized after the import module
# Create new RDPSession in RobotRDPActive
def RDPSessionConnect(inRDPSessionKeyStr, inHostStr, inPortStr, inLoginStr, inPasswordStr):
global gSettings
lRDPConfigurationItem = { # Init the configuration item
"Host": inHostStr, # Host address, example "77.77.22.22"
"Port": inPortStr, # RDP Port, example "3389"

@ -441,6 +441,29 @@
dataType: "text"
});
}
mGlobal.Processor.ServerValueOperatorPlus = function(inKeyList,inValue) {
lData = [
{
"Type":"GlobalDictKeyListValueOperator+",
"KeyList": inKeyList,
"Value": inValue
}
]
///Обнулить таблицу
$('.ui.modal.basic .content').html("");
$.ajax({
type: "POST",
url: 'Utils/Processor',
data: JSON.stringify(lData),
success:
function(lData,l2,l3)
{
var lResponseJSON=JSON.parse(lData)
///TODO Show error if exist error
},
dataType: "text"
});
}
mGlobal.Processor.LogListShow = function() {
lData = [
{

Loading…
Cancel
Save