@ -32,25 +32,31 @@ class Process():
self . mStartCMDStr = inStartCMDStr
self . mStartCMDStr = inStartCMDStr
self . mProcessNameWOExeStr = inProcessNameWOExeStr
self . mProcessNameWOExeStr = inProcessNameWOExeStr
self . mStopSafeTimeoutSecFloat = inStopSafeTimeoutSecFloat
self . mStopSafeTimeoutSecFloat = inStopSafeTimeoutSecFloat
__Orchestrator__ . GSettingsGet ( ) [ " ManagersProcessDict " ] [ inProcessNameWOExeStr . upper ( ) ] = self
__Orchestrator__ . GSettingsGet ( ) [ " ManagersProcessDict " ] [ ( inAgentHostNameStr . upper ( ) , inAgentUserNameStr . upper ( ) , inProcessNameWOExeStr . upper ( ) ) ] = self
self . StatusCheck ( )
lActivityDict = __Orchestrator__ . ProcessorActivityItemCreate ( inDef = self . StatusCheck , inArgList = [ ] )
__Orchestrator__ . ProcessorActivityItemAppend ( inActivityItemDict = lActivityDict )
def Manual2Auto ( self ) :
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 ) :
: return :
: return : Process status . See self . mStatusStr . 0 _STOPPED 1 _STOPPED_MANUAL 2 _STOP_SAFE 3 _STOP_SAFE_MANUAL 4 _STARTED 5 _STARTED_MANUAL
"""
"""
if self . mStatusStr == " 1_STOPPED_MANUAL " : self . mStatusStr = " 0_STOPPED "
lLogBool = False
if self . mStatusStr == " 3_STOP_SAFE_MANUAL " : self . mStatusStr = " 2_STOP_SAFE "
if self . mStatusStr == " 1_STOPPED_MANUAL " : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
if self . mStatusStr == " 5_STARTED_MANUAL " : self . mStatusStr = " 4_STARTED "
if self . mStatusStr == " 3_STOP_SAFE_MANUAL " : self . mStatusStr = " 2_STOP_SAFE " ; lLogBool = True
if self . mStatusStr == " 5_STARTED_MANUAL " : self . mStatusStr = " 4_STARTED " ; lLogBool = True
# Log info about process
if lLogBool == True :
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL . info ( f " Managers.Process: { self . mProcessNameWOExeStr } change status to { self . mStatusStr } ) " )
return self . mStatusStr
def Start ( self , inIsManualBool = True ) :
def Start ( self , inIsManualBool = True ) - > str :
"""
"""
Manual / Auto start . Manual start will block scheduling execution . To return schedule execution use def Manual2Auto
Manual / Auto start . Manual start 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
"""
"""
# 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 ) } "
@ -71,8 +77,9 @@ class Process():
# Log info about process
# Log info about process
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL . info ( f " Managers.Process: { self . mProcessNameWOExeStr } change status to { self . mStatusStr } ) " )
lL . info ( f " Managers.Process: { self . mProcessNameWOExeStr } change status to { self . mStatusStr } ) " )
return self . mStatusStr
def StopSafe ( self , inIsManualBool = True ) :
def StopSafe ( self , inIsManualBool = True ) - > str :
"""
"""
Manual / Auto stop safe . Stop safe is the operation which send signal to process to terminate own work ( send term signal to process ) . Managers . Process wait for the mStopSafeTimeoutSecFloat seconds . After that , if process is not terminated - self will StopForce it .
Manual / Auto stop safe . Stop safe is the operation which send signal to process to terminate own work ( send term signal to process ) . Managers . Process wait for the mStopSafeTimeoutSecFloat seconds . After that , if process is not terminated - self will StopForce it .
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
@ -82,13 +89,13 @@ class Process():
"""
"""
pass
pass
def StopForce ( self , inIsManualBool = True ) :
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 dont 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 :
: 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 /im " { self . mProcessNameWOExeStr } .exe " /fi " username eq %USERNAME% " '
@ -105,7 +112,7 @@ class Process():
# Log info about process
# Log info about process
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL . info ( f " Managers.Process: { self . mProcessNameWOExeStr } change status to { self . mStatusStr } ) " )
lL . info ( f " Managers.Process: { self . mProcessNameWOExeStr } change status to { self . mStatusStr } ) " )
return self . mStatusStr
def RestartSafe ( self , inIsManualBool = True ) :
def RestartSafe ( self , inIsManualBool = True ) :
"""
"""
@ -131,19 +138,26 @@ class Process():
"""
"""
Check if process is alive . The def will save the manual flag is exists .
Check if process is alive . The def will save the manual flag is exists .
: return :
: 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
lLogBool = False
lActivityItemUserProcessList = __Orchestrator__ . ProcessorActivityItemCreate ( inDef = " ProcessWOExeUpperUserListGet " )
lActivityItemUserProcessList = __Orchestrator__ . ProcessorActivityItemCreate ( inDef = " ProcessWOExeUpperUserListGet " )
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 :
if self . mStatusStr == " 1_STOPPED_MANUAL " : self . mStatusStr = " 5_STARTED_MANUAL "
if self . mStatusStr == " 1_STOPPED_MANUAL " : self . mStatusStr = " 5_STARTED_MANUAL " ; lLogBool = True
if self . mStatusStr == " 0_STOPPED " : self . mStatusStr = " 4_STARTED "
if self . mStatusStr == " 0_STOPPED " : self . mStatusStr = " 4_STARTED " ; lLogBool = True
if self . mStatusStr is None : self . mStatusStr = " 4_STARTED " ; lLogBool = True
else :
else :
if self . mStatusStr == " 5_STARTED_MANUAL " : self . mStatusStr = " 1_STOPPED_MANUAL "
if self . mStatusStr == " 5_STARTED_MANUAL " : self . mStatusStr = " 1_STOPPED_MANUAL " ; lLogBool = True
if self . mStatusStr == " 4_STARTED " : self . mStatusStr = " 0_STOPPED "
if self . mStatusStr == " 4_STARTED " : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
if self . mStatusStr is None : self . mStatusStr = " 0_STOPPED " ; lLogBool = True
# Log info about process
if lLogBool == True :
lL = __Orchestrator__ . OrchestratorLoggerGet ( )
lL . info ( f " Managers.Process: { self . mProcessNameWOExeStr } change status to { self . mStatusStr } ) " )
return self . mStatusStr
def StatusCheckStart ( self ) :
def StatusCheckStart ( self ) :
"""
"""
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 "
@ -177,21 +191,25 @@ class Process():
pass
pass
def ProcessGet ( in ProcessNameWOExeStr: str ) - > Process :
def ProcessGet ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str ) - > Process :
"""
"""
Return the process instance by the inProcessNameWOExeStr
Return the process instance by the inProcessNameWOExeStr
: 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: return : Process instance ( if exists ) Else None
: return : Process instance ( if exists ) Else None
"""
"""
return __Orchestrator__ . GSettingsGet ( ) [ " ManagersProcessDict " ] . get ( inProcessNameWOExeStr . upper ( ) , None )
return __Orchestrator__ . GSettingsGet ( ) [ " ManagersProcessDict " ] . get ( ( inAgentHostNameStr . upper ( ) , inAgentUserNameStr . upper ( ) , inProcessNameWOExeStr . upper ( ) ) , None )
def ProcessStatusStrGet ( in ProcessNameWOExeStr ):
def ProcessStatusStrGet ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str ) - > str :
"""
"""
Get the status of the Process instance .
Get the status of the Process instance .
: 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: return : Str
: return : Process status . See self . mStatus Str.
Process instance has the following statuses :
Process instance has the following statuses :
- 0 _STOPPED
- 0 _STOPPED
- 1 _STOPPED_MANUAL
- 1 _STOPPED_MANUAL
@ -201,68 +219,115 @@ def ProcessStatusStrGet(inProcessNameWOExeStr):
- 5 _STARTED_MANUAL
- 5 _STARTED_MANUAL
- None ( if Process instance not exists )
- None ( if Process instance not exists )
"""
"""
lProcess = ProcessGet ( in ProcessNameWOExeStr= inProcessNameWOExeStr )
lProcess = ProcessGet ( in AgentHostNameStr = inAgentHostNameStr , inAgentUserNameStr = inAgentUserNameStr , in ProcessNameWOExeStr= inProcessNameWOExeStr )
if lProcess is not None : return lProcess . mStatusStr
if lProcess is not None : return lProcess . mStatusStr
else : return None
def ProcessStart ( in ProcessNameWOExeStr: str , inIsManualBool : bool = True ) - > None :
def ProcessStart ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str , inIsManualBool : bool = True ) - > str :
"""
"""
Manual / Auto start . Manual start will block scheduling execution . To return schedule execution use def Manual2Auto
Manual / Auto start . Manual start will block scheduling execution . To return schedule execution use def Manual2Auto
: 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: 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 .
Process instance has the following statuses :
- 0 _STOPPED
- 1 _STOPPED_MANUAL
- 2 _STOP_SAFE
- 3 _STOP_SAFE_MANUAL
- 4 _STARTED
- 5 _STARTED_MANUAL
- None ( if Process instance not exists )
"""
"""
lProcess = ProcessGet ( inProcessNameWOExeStr = inProcessNameWOExeStr )
lProcess = ProcessGet ( in AgentHostNameStr = inAgentHostNameStr , inAgentUserNameStr = inAgentUserNameStr , in ProcessNameWOExeStr= inProcessNameWOExeStr )
if lProcess is not None : return lProcess . Start ( inIsManualBool = inIsManualBool )
if lProcess is not None : return lProcess . Start ( inIsManualBool = inIsManualBool )
else : return None
def ProcessStopSafe ( inProcessNameWOExeStr : str , inIsManualBool : bool = True ) - > None :
def ProcessStopSafe ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str , inIsManualBool : bool = True ) - > str :
"""
"""
Manual / Auto stop safe . Stop safe is the operation which send signal to process to terminate own work ( send term signal to process ) . Managers . Process wait for the mStopSafeTimeoutSecFloat seconds . After that , if process is not terminated - self will StopForce it .
Manual / Auto stop safe . Stop safe is the operation which send signal to process to terminate own work ( send term signal to process ) . Managers . Process wait for the mStopSafeTimeoutSecFloat seconds . After that , if process is not terminated - self will StopForce it .
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 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: 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 .
Process instance has the following statuses :
- 0 _STOPPED
- 1 _STOPPED_MANUAL
- 2 _STOP_SAFE
- 3 _STOP_SAFE_MANUAL
- 4 _STARTED
- 5 _STARTED_MANUAL
- None ( if Process instance not exists )
"""
"""
lProcess = ProcessGet ( inProcessNameWOExeStr = inProcessNameWOExeStr )
lProcess = ProcessGet ( in AgentHostNameStr = inAgentHostNameStr , inAgentUserNameStr = inAgentUserNameStr , in ProcessNameWOExeStr= inProcessNameWOExeStr )
if lProcess is not None : return lProcess . StopSafe ( inIsManualBool = inIsManualBool )
if lProcess is not None : return lProcess . StopSafe ( inIsManualBool = inIsManualBool )
else : return None
def ProcessStopForce ( inProcessNameWOExeStr : str , inIsManualBool : bool = True ) - > None :
def ProcessStopForce ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str , inIsManualBool : bool = True ) - > str :
"""
"""
Manual / Auto stop force . Force stop dont wait process termination - it just terminate process now .
Manual / Auto stop force . Force stop dont 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 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: 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 .
Process instance has the following statuses :
- 0 _STOPPED
- 1 _STOPPED_MANUAL
- 2 _STOP_SAFE
- 3 _STOP_SAFE_MANUAL
- 4 _STARTED
- 5 _STARTED_MANUAL
- None ( if Process instance not exists )
"""
"""
lProcess = ProcessGet ( inProcessNameWOExeStr = inProcessNameWOExeStr )
lProcess = ProcessGet ( in AgentHostNameStr = inAgentHostNameStr , inAgentUserNameStr = inAgentUserNameStr , in ProcessNameWOExeStr= inProcessNameWOExeStr )
if lProcess is not None : return lProcess . StopForce ( inIsManualBool = inIsManualBool )
if lProcess is not None : return lProcess . StopForce ( inIsManualBool = inIsManualBool )
else : return None
def ProcessStatusCheck ( inProcessNameWOExeStr : str ) - > str :
def ProcessStatusCheck ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str ) - > str :
"""
"""
Check if process is alive . The def will save the manual flag is exists .
Check if process is alive . The def will save the manual flag is exists .
: 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: return : str : Check process status and return it
: return : Process status . See self . mStatusStr .
Process instance has the following statuses :
- 0 _STOPPED
- 1 _STOPPED_MANUAL
- 2 _STOP_SAFE
- 3 _STOP_SAFE_MANUAL
- 4 _STARTED
- 5 _STARTED_MANUAL
- None ( if Process instance not exists )
"""
"""
lProcess = ProcessGet ( inProcessNameWOExeStr = inProcessNameWOExeStr )
lProcess = ProcessGet ( inAgentHostNameStr = inAgentHostNameStr , inAgentUserNameStr = inAgentUserNameStr ,
inProcessNameWOExeStr = inProcessNameWOExeStr )
if lProcess is not None :
if lProcess is not None :
lProcess . StatusCheck ( )
lProcess . StatusCheck ( )
return lProcess . mStatusStr
return lProcess . mStatusStr
else : return None
def ProcessManual2Auto ( inProcessNameWOExeStr : str ) - > None :
def ProcessManual2Auto ( in AgentHostNameStr: str , inAgentUserNameStr : str , in ProcessNameWOExeStr: str ) - > 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 ) :
: 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 inProcessNameWOExeStr : The process name without extension . exe ( the key of the Process instance ) . Any case - will be processed to the upper case
: return : None
: return : Process status . See self . mStatusStr .
Process instance has the following statuses :
- 0 _STOPPED
- 1 _STOPPED_MANUAL
- 2 _STOP_SAFE
- 3 _STOP_SAFE_MANUAL
- 4 _STARTED
- 5 _STARTED_MANUAL
- None ( if Process instance not exists )
"""
"""
lProcess = ProcessGet ( inProcessNameWOExeStr = inProcessNameWOExeStr )
lProcess = ProcessGet ( inAgentHostNameStr = inAgentHostNameStr , inAgentUserNameStr = inAgentUserNameStr ,
if lProcess is not None : lProcess . Manual2Auto ( )
inProcessNameWOExeStr = inProcessNameWOExeStr )
if lProcess is not None : return lProcess . Manual2Auto ( )