#Orchestrator_LoopActivityTested

dev-linux
Ivan Maslov 6 years ago
parent 18ae510488
commit 97434690c1

@ -0,0 +1,3 @@
cd %~dp0
.\..\Resources\WPy32-3720\python-3.7.2\python.exe
pause >nul

@ -54,11 +54,12 @@
},
{
"activityType":"loopActivity",
"loopSeconds":4,
"loopTimeStart":"23:34",
"loopTimeEnd":"23:35",
"pythonPackageName":"",
"pythonFunctionName":"",
"loopSeconds":6,
"loopTimeStart":"01:45",
"loopTimeEnd":"01:46",
"pythonPackageName":"CheckActivity",
"pythonFunctionName":"test_activity",
"pythonFunctionArgList":["TestArg1","TestArg2"],
"processPath":"notepad",
"processArgs":""
}

@ -108,11 +108,11 @@ while True:
#Запись в массив отработанных активностей
lDaemonActivityLogDict[(lItem["activityType"],lActivityDateTime,lItem["processPath"])]={"ActivityStartDateTime":lCurrentDateTime}
lActivityTimeEndDateTime=datetime.datetime.strptime(lItem["loopTimeEnd"],"%H:%M")
lActivityTimeEndDateTime=lActivityDateTime.replace(year=lCurrentDateTime.year,month=lCurrentDateTime.month,day=lCurrentDateTime.day)
lActivityTimeEndDateTime=lActivityTimeEndDateTime.replace(year=lCurrentDateTime.year,month=lCurrentDateTime.month,day=lCurrentDateTime.day)
#Лог
lGlobalDict["ActivityLogScheduleList"].append({"activityType":lItem["activityType"], "activityDateTime":str(lActivityDateTime), "processPath":lItem["processPath"], "activityStartDateTime":str(lCurrentDateTime)})
#Запуск циклической процедуры
orchestratorTimer.activityLoopStart(1,lItem["processPath"],lItem["processArgs"],lActivityTimeEndDateTime,lItem["pythonPackageName"],lItem["pythonFunctionName"])
orchestratorTimer.activityLoopStart(lItem["loopSeconds"],lItem["processPath"],lItem["processArgs"],lActivityTimeEndDateTime,lItem["pythonPackageName"],lItem["pythonFunctionName"],lItem["pythonFunctionArgList"])
#Уснуть до следующего прогона
time.sleep(lDaemonLoopSeconds)

@ -30,7 +30,7 @@ class RepeatedTimer(object):
############################################################
####Техническая функция обработки таймера - потока
############################################################
def activityLoopExecution(inProcessPath,inProcessArgList,inLoopTimeEndDateTime,inPythonPackageName,inPythonFunctionName):
def activityLoopExecution(inProcessPath,inProcessArgList,inLoopTimeEndDateTime,inPythonPackageName,inPythonFunctionName,inPythonFunctionArgList=[]):
lResultGoLoop=True
lCurrentDateTime=datetime.datetime.now()
print (datetime.datetime.now().isoformat()+":: Loop activity check")
@ -49,6 +49,7 @@ def activityLoopExecution(inProcessPath,inProcessArgList,inLoopTimeEndDateTime,i
lModule=importlib.import_module(inPythonPackageName)
#Найти функцию
lFunction=getattr(lModule,inPythonFunctionName)
lFunction(*inPythonFunctionArgList)
except Exception as e:
print (datetime.datetime.now().isoformat()+":: Loop activity error: module/function not founded")
@ -60,6 +61,6 @@ def activityLoopExecution(inProcessPath,inProcessArgList,inLoopTimeEndDateTime,i
############################################################
####Функция запуска таймера - потока
############################################################
def activityLoopStart(inActivityLoopSeconds,inProcessPath,inProcessArgList,inLoopTimeEndDateTime,inPythonPackageName,inPythonFunctionName):
lTimer = RepeatedTimer(inActivityLoopSeconds, activityLoopExecution, inProcessPath,inProcessArgList,inLoopTimeEndDateTime,inPythonPackageName,inPythonFunctionName) # it auto-starts, no need of rt.start()
def activityLoopStart(inActivityLoopSeconds,inProcessPath,inProcessArgList,inLoopTimeEndDateTime,inPythonPackageName,inPythonFunctionName,inPythonFunctionArgList=[]):
lTimer = RepeatedTimer(inActivityLoopSeconds, activityLoopExecution, inProcessPath,inProcessArgList,inLoopTimeEndDateTime,inPythonPackageName,inPythonFunctionName,inPythonFunctionArgList) # it auto-starts, no need of rt.start()
lTimer.start()

Loading…
Cancel
Save