Fix Web Def Helper (save last params in dict)

Test Process add Mute utility to save the process interactions

# next todo: form of schedule - has until but not has 'from'
# next todo: create def to check safe signal termination
dev-linux test
Ivan Maslov 3 years ago
parent bedcd24652
commit 2ad58efa4f

@ -41,6 +41,19 @@ class Process():
mMSTdNInt = None mMSTdNInt = None
mMSTStartTimeList = [] mMSTStartTimeList = []
mAgentMuteBool = False # Mute any sends to agent while some action is perfomed
def MuteWait(self):
"""
Internal def. Wait when class is apply to send new activities to the agent
:return:
"""
lIntervalSecFloat = 0.3
while self.mAgentMuteBool == True:
time.sleep(lIntervalSecFloat)
return None
def __init__(self, inAgentHostNameStr, inAgentUserNameStr, inProcessNameWOExeStr, inStartPathStr=None, inStartCMDStr = None, inStopSafeTimeoutSecFloat=120): def __init__(self, inAgentHostNameStr, inAgentUserNameStr, inProcessNameWOExeStr, inStartPathStr=None, inStartCMDStr = None, inStopSafeTimeoutSecFloat=120):
self.mAgentHostNameStr = inAgentHostNameStr self.mAgentHostNameStr = inAgentHostNameStr
self.mAgentUserNameStr = inAgentUserNameStr self.mAgentUserNameStr = inAgentUserNameStr
@ -83,9 +96,21 @@ class Process():
if ldTSecFloat < self.mMSTdTSecFloat: lMSTStartTimeList.append(lTimeItemSecFloat) if ldTSecFloat < self.mMSTdTSecFloat: lMSTStartTimeList.append(lTimeItemSecFloat)
self.mMSTStartTimeList = lMSTStartTimeList # Set new list self.mMSTStartTimeList = lMSTStartTimeList # Set new list
# Check count in list # Check count in list
if len(lMSTStartTimeList) > self.mMSTdNInt: self.mStatusStr = "1_STOPPED_MANUAL" if len(lMSTStartTimeList) > self.mMSTdNInt:
self.mStatusStr = "1_STOPPED_MANUAL"
# Log info about process
lL = __Orchestrator__.OrchestratorLoggerGet()
lL.info(f"Managers.Process ({self.mAgentHostNameStr}, {self.mAgentUserNameStr}, {self.mProcessNameWOExeStr}): ManualStopTrigger is activated. {self.mMSTdNInt} start tries in {self.mMSTdTSecFloat} sec.")
return self.mStatusStr return self.mStatusStr
def ManualStopListClear(self) -> None:
"""
Clear the last start tries list.
:return: None
"""
self.mMSTStartTimeList=[]
def Manual2Auto(self) -> str: def Manual2Auto(self) -> str:
""" """
Remove Manual flag from process (if exists) - it will allow the schedule operations via def StatusCheckStart(self): def StatusCheckStorForce(self): def StatusCheckStopSafe(self): Remove Manual flag from process (if exists) - it will allow the schedule operations via def StatusCheckStart(self): def StatusCheckStorForce(self): def StatusCheckStopSafe(self):
@ -108,17 +133,18 @@ class Process():
:param inIsManualBool: Default is True - Mark this operation as manual - StatusCheckStart/Stop will be blocked - only StatusCheck will be working. False - Auto operation :param inIsManualBool: Default is True - Mark this operation as manual - StatusCheckStart/Stop will be blocked - only StatusCheck will be working. False - Auto operation
:return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL :return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL
""" """
if inIsManualBool == False: self.ManualStopTriggerNewStart() # Set the time
if (self.mStatusStr == "1_STOPPED_MANUAL" or "STOP_SAFE" in self.mStatusStr) and inIsManualBool == False: if (self.mStatusStr == "1_STOPPED_MANUAL" or "STOP_SAFE" in self.mStatusStr) and inIsManualBool == False:
lStr = f"Managers.Process ({self.mAgentHostNameStr}, {self.mAgentUserNameStr}, {self.mProcessNameWOExeStr}): Process will not start because of stopped manual or stop safe is now." lStr = f"Managers.Process ({self.mAgentHostNameStr}, {self.mAgentUserNameStr}, {self.mProcessNameWOExeStr}): Process will not start because of stopped manual or stop safe is now."
__Orchestrator__.OrchestratorLoggerGet().warning(lStr) __Orchestrator__.OrchestratorLoggerGet().warning(lStr)
return self.mStatusStr return self.mStatusStr
if inIsManualBool == False: self.ManualStopTriggerNewStart() # Set the time
# Send activity item to agent - wait result # Send activity item to agent - wait result
if self.mStartPathStr is not None: lCMDStr = f"start {os.path.abspath(self.mStartPathStr)}" if self.mStartPathStr is not None: lCMDStr = f"start {os.path.abspath(self.mStartPathStr)}"
elif self.mStartCMDStr is not None: lCMDStr = f"start {self.mStartCMDStr}" elif self.mStartCMDStr is not None: lCMDStr = f"start {self.mStartCMDStr}"
#import pdb #import pdb
#pdb.set_trace() #pdb.set_trace()
self.MuteWait()
self.mAgentMuteBool=True
lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate(inDef="OSCMD", lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate(inDef="OSCMD",
inArgDict={"inCMDStr":lCMDStr,"inSendOutputToOrchestratorLogsBool":False}, inArgDict={"inCMDStr":lCMDStr,"inSendOutputToOrchestratorLogsBool":False},
inArgGSettingsStr="inGSettings") inArgGSettingsStr="inGSettings")
@ -132,6 +158,7 @@ class Process():
self.mStatusStr = "4_STARTED" self.mStatusStr = "4_STARTED"
# Log info about process # Log info about process
self.StatusChangeLog() self.StatusChangeLog()
self.mAgentMuteBool = False
return self.mStatusStr return self.mStatusStr
def StartCheck(self) -> str: def StartCheck(self) -> str:
@ -140,6 +167,7 @@ class Process():
:return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL :return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL
""" """
self.MuteWait()
if self.mStatusStr == "0_STOPPED": if self.mStatusStr == "0_STOPPED":
self.Start(inIsManualBool=False) self.Start(inIsManualBool=False)
return self.mStatusStr return self.mStatusStr
@ -152,7 +180,8 @@ class Process():
:param inIsManualBool: Default is True - Mark this operation as manual - StatusCheckStart/Stop will be blocked - only StatusCheck will be working. False - Auto operation :param inIsManualBool: Default is True - Mark this operation as manual - StatusCheckStart/Stop will be blocked - only StatusCheck will be working. False - Auto operation
:return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL :return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL
""" """
self.MuteWait()
self.mAgentMuteBool=True
# Send activity item to agent - wait result # Send activity item to agent - wait result
lCMDStr = f'taskkill /im "{self.mProcessNameWOExeStr}.exe" /fi "username eq %USERNAME%"' lCMDStr = f'taskkill /im "{self.mProcessNameWOExeStr}.exe" /fi "username eq %USERNAME%"'
lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate( lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate(
@ -180,6 +209,7 @@ class Process():
self.StopForce(inIsManualBool=inIsManualBool) self.StopForce(inIsManualBool=inIsManualBool)
# Log info about process # Log info about process
self.StatusChangeLog() self.StatusChangeLog()
self.mAgentMuteBool=False
return self.mStatusStr return self.mStatusStr
def StopSafeCheck(self) -> str: def StopSafeCheck(self) -> str:
@ -188,6 +218,7 @@ class Process():
:return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL :return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL
""" """
self.MuteWait()
if self.mStatusStr == "4_STARTED": if self.mStatusStr == "4_STARTED":
self.StopSafe(inIsManualBool=False) self.StopSafe(inIsManualBool=False)
return self.mStatusStr return self.mStatusStr
@ -200,6 +231,8 @@ class Process():
:param inIsManualBool: Default is True - Mark this operation as manual - StatusCheckStart/Stop will be blocked - only StatusCheck will be working. False - Auto operation :param inIsManualBool: Default is True - Mark this operation as manual - StatusCheckStart/Stop will be blocked - only StatusCheck will be working. False - Auto operation
:return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL :return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL
""" """
self.MuteWait()
self.mAgentMuteBool=True
# Send activity item to agent - wait result # Send activity item to agent - wait result
lCMDStr = f'taskkill /F /im "{self.mProcessNameWOExeStr}.exe" /fi "username eq %USERNAME%"' lCMDStr = f'taskkill /F /im "{self.mProcessNameWOExeStr}.exe" /fi "username eq %USERNAME%"'
lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate( lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate(
@ -214,6 +247,7 @@ class Process():
self.mStatusStr = "0_STOPPED" self.mStatusStr = "0_STOPPED"
# Log info about process # Log info about process
self.StatusChangeLog() self.StatusChangeLog()
self.mAgentMuteBool=False
return self.mStatusStr return self.mStatusStr
def StopForceCheck(self) -> str: def StopForceCheck(self) -> str:
@ -222,6 +256,7 @@ class Process():
:return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL :return: Process status. See self.mStatusStr. 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL
""" """
self.MuteWait()
if self.mStatusStr == "4_STARTED": if self.mStatusStr == "4_STARTED":
self.StopForce(inIsManualBool=False) self.StopForce(inIsManualBool=False)
return self.mStatusStr return self.mStatusStr
@ -268,6 +303,8 @@ class Process():
# Send activity item to agent - wait result # Send activity item to agent - wait result
lLogBool = False lLogBool = False
lActivityItemUserProcessList = __Orchestrator__.ProcessorActivityItemCreate(inDef="ProcessWOExeUpperUserListGet") lActivityItemUserProcessList = __Orchestrator__.ProcessorActivityItemCreate(inDef="ProcessWOExeUpperUserListGet")
self.MuteWait()
self.mAgentMuteBool=True
lGUIDStr = __Orchestrator__.AgentActivityItemAdd(inHostNameStr=self.mAgentHostNameStr,inUserStr=self.mAgentUserNameStr,inActivityItemDict=lActivityItemUserProcessList) lGUIDStr = __Orchestrator__.AgentActivityItemAdd(inHostNameStr=self.mAgentHostNameStr,inUserStr=self.mAgentUserNameStr,inActivityItemDict=lActivityItemUserProcessList)
lUserProcessList = __Orchestrator__.AgentActivityItemReturnGet(inGUIDStr=lGUIDStr) lUserProcessList = __Orchestrator__.AgentActivityItemReturnGet(inGUIDStr=lGUIDStr)
if self.mProcessNameWOExeStr.upper() in lUserProcessList: if self.mProcessNameWOExeStr.upper() in lUserProcessList:
@ -282,6 +319,7 @@ class Process():
if self.mStatusStr is None: self.mStatusStr = "0_STOPPED"; lLogBool=True if self.mStatusStr is None: self.mStatusStr = "0_STOPPED"; lLogBool=True
# Log info about process # Log info about process
if lLogBool == True: self.StatusChangeLog() if lLogBool == True: self.StatusChangeLog()
self.mAgentMuteBool = False
return self.mStatusStr return self.mStatusStr
def StatusCheckStart(self): def StatusCheckStart(self):
""" """
@ -464,4 +502,33 @@ def ProcessManual2Auto(inAgentHostNameStr: str, inAgentUserNameStr: str, inProce
""" """
lProcess = ProcessGet(inAgentHostNameStr=inAgentHostNameStr, inAgentUserNameStr=inAgentUserNameStr, lProcess = ProcessGet(inAgentHostNameStr=inAgentHostNameStr, inAgentUserNameStr=inAgentUserNameStr,
inProcessNameWOExeStr=inProcessNameWOExeStr) inProcessNameWOExeStr=inProcessNameWOExeStr)
if lProcess is not None: return lProcess.Manual2Auto() if lProcess is not None: return lProcess.Manual2Auto()
def ProcessManualStopTriggerSet(inAgentHostNameStr: str, inAgentUserNameStr: str, inProcessNameWOExeStr: str, inMSTdTSecFloat: float, inMSTdNInt: int) -> None:
"""
Remove Manual flag from process (if exists) - it will allow the schedule operations via def StatusCheckStart(self): def StatusCheckStorForce(self): def StatusCheckStopSafe(self):
:param inAgentHostNameStr: Agent hostname in any case. Required to identify Process
:param inAgentUserNameStr: Agent user name in any case. Required to identify Process
:param inProcessNameWOExeStr: The process name without extension .exe (the key of the Process instance). Any case - will be processed to the upper case
:param inMSTdTSecFloat: Time periods in seconds
:param inMSTdNInt: Counts of the start tries
:return: None
"""
lProcess = ProcessGet(inAgentHostNameStr=inAgentHostNameStr, inAgentUserNameStr=inAgentUserNameStr,
inProcessNameWOExeStr=inProcessNameWOExeStr)
if lProcess is not None: lProcess.ManualStopTriggerSet(inMSTdTSecFloat = inMSTdTSecFloat, inMSTdNInt = inMSTdNInt)
def ProcessManualStopListClear(inAgentHostNameStr: str, inAgentUserNameStr: str, inProcessNameWOExeStr: str) -> None:
"""
Clear the last start tries list.
:param inAgentHostNameStr: Agent hostname in any case. Required to identify Process
:param inAgentUserNameStr: Agent user name in any case. Required to identify Process
:param inProcessNameWOExeStr: The process name without extension .exe (the key of the Process instance). Any case - will be processed to the upper case
:return: None
"""
lProcess = ProcessGet(inAgentHostNameStr=inAgentHostNameStr, inAgentUserNameStr=inAgentUserNameStr,
inProcessNameWOExeStr=inProcessNameWOExeStr)
if lProcess is not None: lProcess.ManualStopListClear()

@ -898,18 +898,11 @@ $(document).ready(function() {
//////////////////////////////////////////// ////////////////////////////////////////////
// 1.2.7 Debugging // 1.2.7 Debugging
/// Execute ActivityItem /// Execute ActivityItem
// 1.2.7 Debugging toolbox init
$('.ui.dropdown.mGlobal-pyOpenRPA-Debugging-Def-Dropdown')
.dropdown({
apiSettings: {
// this url parses query server side and returns filtered results
url: '/pyOpenRPA/Debugging/HelperDefList/{query}'
},
})
;
// Debugging onchange def autofill init // Debugging onchange def autofill init
$('.ui.dropdown.mGlobal-pyOpenRPA-Debugging-Def-Dropdown')[0].onchange=function(inEvent){ var lDropdownOnChange = function(inEvent){
lValueStr = inEvent.target.value //lValueStr = inEvent.target.value
lValueStr = inEvent
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: '/pyOpenRPA/Debugging/HelperDefAutofill/'+lValueStr, url: '/pyOpenRPA/Debugging/HelperDefAutofill/'+lValueStr,
@ -937,6 +930,8 @@ $(document).ready(function() {
dataType: "text" dataType: "text"
}); });
} }
//$('.ui.dropdown.mGlobal-pyOpenRPA-Debugging-Def-Dropdown')[0].onchange=lDropdownOnChange
mGlobal.pyOpenRPA.DebuggingExecute=function() { mGlobal.pyOpenRPA.DebuggingExecute=function() {
@ -985,4 +980,14 @@ $(document).ready(function() {
} }
return inTargetDict return inTargetDict
} }
// 1.2.7 Debugging toolbox init
$('.ui.dropdown.mGlobal-pyOpenRPA-Debugging-Def-Dropdown')
.dropdown({
apiSettings: {
// this url parses query server side and returns filtered results
url: '/pyOpenRPA/Debugging/HelperDefList/{query}'
},
onChange: lDropdownOnChange
})
;
}); });
Loading…
Cancel
Save