@ -1,7 +1,7 @@
#from pyOpenRPA.Orchestrator import Managers
#from pyOpenRPA.Orchestrator import Managers
from . . import __Orchestrator__
from . . import __Orchestrator__
import os
import os
import time
class Process ( ) :
class Process ( ) :
"""
"""
Manager process , which is need to be started / stopped / restarted
Manager process , which is need to be started / stopped / restarted
@ -83,20 +83,48 @@ class Process():
Manual stop safe will block scheduling execution . To return schedule execution use def Manual2Auto
Manual stop safe will block scheduling execution . To return schedule execution use def Manual2Auto
: 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 :
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
"""
pass
# Send activity item to agent - wait result
lCMDStr = f ' taskkill /im " { self . mProcessNameWOExeStr } .exe " /fi " username eq %USERNAME% " '
lActivityItemStart = __Orchestrator__ . ProcessorActivityItemCreate (
inDef = " OSCMD " , inArgDict = { " inCMDStr " : lCMDStr , " inSendOutputToOrchestratorLogsBool " : False } , inArgGSettingsStr = " inGSettings " )
lGUIDStr = __Orchestrator__ . AgentActivityItemAdd ( inHostNameStr = self . mAgentHostNameStr ,
inUserStr = self . mAgentUserNameStr ,
inActivityItemDict = lActivityItemStart )
lStartResult = __Orchestrator__ . AgentActivityItemReturnGet ( inGUIDStr = lGUIDStr )
if inIsManualBool == True :
self . mStatusStr = " 3_STOP_SAFE_MANUAL "
else :
self . mStatusStr = " 2_STOP_SAFE "
# Log info about process
self . StatusChangeLog ( )
# Interval check is stopped
lTimeStartFloat = time . time ( )
lIntervalCheckSafeStatusFLoat = 15.0
while " SAFE " in self . mStatusStr and ( time . time ( ) - lTimeStartFloat ) < self . mStopSafeTimeoutSecFloat :
self . StatusCheck ( )
time . sleep ( lIntervalCheckSafeStatusFLoat )
if " SAFE " in self . mStatusStr :
# Log info about process
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL . info ( f " Managers.Process ( { self . mAgentHostNameStr } , { self . mAgentUserNameStr } , { self . mProcessNameWOExeStr } ): Safe stop has been wait for { self . mStopSafeTimeoutSecFloat } sec. Now do the force stop. " )
self . StopForce ( inIsManualBool = inIsManualBool )
# Log info about process
self . StatusChangeLog ( )
return self . mStatusStr
def StopForce ( self , inIsManualBool = True ) - > str :
def StopForce ( self , inIsManualBool = True ) - > str :
"""
"""
Manual / Auto stop force . Force stop dont wait process termination - it just terminate process now .
Manual / Auto stop force . Force stop don ' t wait process termination - it just terminate process now .
Manual stop safe will block scheduling execution . To return schedule execution use def Manual2Auto
Manual stop safe will block scheduling execution . To return schedule execution use def Manual2Auto
: 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
"""
"""
# 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 / F / im " { self . mProcessNameWOExeStr } .exe " /fi " username eq %USERNAME% " '
lActivityItemStart = __Orchestrator__ . ProcessorActivityItemCreate (
lActivityItemStart = __Orchestrator__ . ProcessorActivityItemCreate (
inDef = " OSCMD " , inArgDict = { " inCMDStr " : lCMDStr , " inSendOutputToOrchestratorLogsBool " : False } , inArgGSettingsStr = " inGSettings " )
inDef = " OSCMD " , inArgDict = { " inCMDStr " : lCMDStr , " inSendOutputToOrchestratorLogsBool " : False } , inArgGSettingsStr = " inGSettings " )
lGUIDStr = __Orchestrator__ . AgentActivityItemAdd ( inHostNameStr = self . mAgentHostNameStr ,
lGUIDStr = __Orchestrator__ . AgentActivityItemAdd ( inHostNameStr = self . mAgentHostNameStr ,
@ -117,9 +145,10 @@ class Process():
Manual stop safe will block scheduling execution . To return schedule execution use def Manual2Auto
Manual stop safe will block scheduling execution . To return schedule execution use def Manual2Auto
: 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 :
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
"""
pass
self . StopSafe ( inIsManualBool = inIsManualBool )
return self . Start ( inIsManualBool = inIsManualBool )
def RestartForce ( self , inIsManualBool = True ) :
def RestartForce ( self , inIsManualBool = True ) :
"""
"""
@ -127,9 +156,10 @@ class Process():
Manual restart will block scheduling execution . To return schedule execution use def Manual2Auto
Manual restart will block scheduling execution . To return schedule execution use def Manual2Auto
: 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 :
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
"""
pass
self . StopForce ( inIsManualBool = inIsManualBool )
return self . Start ( inIsManualBool = inIsManualBool )
def StatusChangeLog ( self ) :
def StatusChangeLog ( self ) :
"""
"""
@ -158,6 +188,8 @@ class Process():
if self . mStatusStr == " 0_STOPPED " : self . mStatusStr = " 4_STARTED " ; lLogBool = True
if self . mStatusStr == " 0_STOPPED " : self . mStatusStr = " 4_STARTED " ; lLogBool = True
if self . mStatusStr is None : self . mStatusStr = " 4_STARTED " ; lLogBool = True
if self . mStatusStr is None : self . mStatusStr = " 4_STARTED " ; lLogBool = True
else :
else :
if self . mStatusStr == " 2_STOP_SAFE " : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
if self . mStatusStr == " 3_STOP_SAFE_MANUAL " : self . mStatusStr = " 1_STOPPED_MANUAL " ; lLogBool = True
if self . mStatusStr == " 5_STARTED_MANUAL " : self . mStatusStr = " 1_STOPPED_MANUAL " ; lLogBool = True
if self . mStatusStr == " 5_STARTED_MANUAL " : self . mStatusStr = " 1_STOPPED_MANUAL " ; lLogBool = True
if self . mStatusStr == " 4_STARTED " : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
if self . mStatusStr == " 4_STARTED " : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
if self . mStatusStr is None : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
if self . mStatusStr is None : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
@ -168,17 +200,22 @@ class Process():
"""
"""
Check process status and run it if auto stopped self . mStatusStr is " 0_STOPPED "
Check process status and run it if auto stopped self . mStatusStr is " 0_STOPPED "
: return :
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
"""
pass
lStatusStr = self . StatusCheck ( )
if lStatusStr == " 0_STOPPED " :
self . Start ( inIsManualBool = False )
return self . mStatusStr
def StatusCheckStopForce ( self ) :
def StatusCheckStopForce ( self ) :
"""
"""
Check process status and auto stop force it if self . mStatusStr is 4 _STARTED
Check process status and auto stop force it if self . mStatusStr is 4 _STARTED
: return :
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
"""
pass
lStatusStr = self . StatusCheck ( )
if lStatusStr == " 4_STARTED " :
self . StopForce ( inIsManualBool = False )
return self . mStatusStr
def StatusCheckStopSafe ( self ) :
def StatusCheckStopSafe ( self ) :
"""
"""
@ -186,15 +223,10 @@ class Process():
: return :
: return :
"""
"""
pass
lStatusStr = self . StatusCheck ( )
if lStatusStr == " 4_STARTED " :
def ScheduleWeekDay ( self ) :
self . StopSafe ( inIsManualBool = False )
"""
return self . mStatusStr
Some template def to work with schedule package . Configure schedule to start . Stop process in auto mode in all sele .
: return :
"""
pass
def ProcessGet ( inAgentHostNameStr : str , inAgentUserNameStr : str , inProcessNameWOExeStr : str ) - > Process :
def ProcessGet ( inAgentHostNameStr : str , inAgentUserNameStr : str , inProcessNameWOExeStr : str ) - > Process :