diff --git a/Orchestrator/PythonDebug_32.cmd b/Orchestrator/PythonDebug_32.cmd new file mode 100644 index 00000000..eca1167e --- /dev/null +++ b/Orchestrator/PythonDebug_32.cmd @@ -0,0 +1,3 @@ +cd %~dp0 +.\..\Resources\WPy32-3720\python-3.7.2\python.exe +pause >nul \ No newline at end of file diff --git a/Orchestrator/orchestratorConfiguration.json b/Orchestrator/orchestratorConfiguration.json index 7b19a57e..578539f9 100644 --- a/Orchestrator/orchestratorConfiguration.json +++ b/Orchestrator/orchestratorConfiguration.json @@ -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":"" } diff --git a/Orchestrator/orchestratorMain.py b/Orchestrator/orchestratorMain.py index b84c72e0..049c818b 100644 --- a/Orchestrator/orchestratorMain.py +++ b/Orchestrator/orchestratorMain.py @@ -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) diff --git a/Orchestrator/orchestratorTimer.py b/Orchestrator/orchestratorTimer.py index e7164c23..6284d2ea 100644 --- a/Orchestrator/orchestratorTimer.py +++ b/Orchestrator/orchestratorTimer.py @@ -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()