From 29a21f1ad70b124ae5ae3a5b0b2602451389e700 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Fri, 1 Nov 2019 23:40:36 +0300 Subject: [PATCH] =?UTF-8?q?1.=20[+]=20=D0=A3=D0=B1=D1=80=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B5=D1=84=D0=B8=D0=BA=D1=81=20orchestrator=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=20=D0=BA=D0=B0=D0=BA=20=D0=BE=D0=BD=20=D0=B8?= =?UTF-8?q?=20=D1=82=D0=B0=D0=BA=20=D0=BD=D0=B0=D1=85=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=B2=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B5=20?= =?UTF-8?q?Orchestrator/=20OrchestratorMain=20>=20Orchestrator=202.=20[+]?= =?UTF-8?q?=20=D0=9A=D0=BE=D0=BD=D1=81=D0=BE=D0=BB=D0=B8=D0=B4=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=81=D0=B5=D1=85=20?= =?UTF-8?q?=D0=B4=D0=B5=D0=B9=D1=81=D1=82=D0=B2=D0=B8=D0=B9=20=D1=87=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=20orchestratorProcessor=203.=20[+]=20=D0=A1?= =?UTF-8?q?=D0=B2=D0=B5=D1=81=D1=82=D0=B8=20=D0=B2=20=D0=BF=D0=BB=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=D1=80=D0=BD=D1=83=D1=8E=20=D1=81=D1=82=D1=80=D1=83?= =?UTF-8?q?=D0=BA=D1=82=D1=83=D1=80=D1=83=20inConfiguration.=20=D0=9B?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=20=D1=81=D0=B5=D0=B9=D1=87=D0=B0=D1=81=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D1=83=D1=8E=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=B7=D0=B0=20=D0=BF=D1=80=D0=B5=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=20=D1=8D=D1=82=D0=BE=D0=B9=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=8B=20-=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BD=D0=B8=D0=BA=D0=B0=D0=B5=D1=82=20=D0=B4=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9=D0=BD=D0=BE=D0=B5=20=D1=82=D1=80=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=204.=20[+]=20=D0=A0=D0=B5=D1=84?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=86=D0=B0=20=D0=B2=D0=BC?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B5=20=D1=81=20=D0=BA=D0=BE=D0=BD=D1=81?= =?UTF-8?q?=D0=BE=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D0=B5=D0=B9=20orches?= =?UTF-8?q?tratorProcessor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Orchestrator/.idea/.gitignore | 3 ++ Orchestrator/.idea/Orchestrator.iml | 11 +++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ Orchestrator/.idea/modules.xml | 8 ++++ Orchestrator/.idea/vcs.xml | 6 +++ Orchestrator/OpenRPAOrchestratorRun_x32.cmd | 2 +- Orchestrator/OpenRPAOrchestratorRun_x64.cmd | 2 +- .../{orchestratorMain.py => Orchestrator.py} | 40 +++++----------- ...{orchestratorProcessor.py => Processor.py} | 0 .../{orchestratorServer.py => Server.py} | 48 ++++--------------- .../{orchestratorTimer.py => Timer.py} | 4 +- Orchestrator/todo.txt | 8 ++-- v1.0.4 => v1.0.5 | 0 13 files changed, 63 insertions(+), 75 deletions(-) create mode 100644 Orchestrator/.idea/.gitignore create mode 100644 Orchestrator/.idea/Orchestrator.iml create mode 100644 Orchestrator/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 Orchestrator/.idea/modules.xml create mode 100644 Orchestrator/.idea/vcs.xml rename Orchestrator/{orchestratorMain.py => Orchestrator.py} (80%) rename Orchestrator/{orchestratorProcessor.py => Processor.py} (100%) rename Orchestrator/{orchestratorServer.py => Server.py} (77%) rename Orchestrator/{orchestratorTimer.py => Timer.py} (95%) rename v1.0.4 => v1.0.5 (100%) diff --git a/Orchestrator/.idea/.gitignore b/Orchestrator/.idea/.gitignore new file mode 100644 index 00000000..0e40fe8f --- /dev/null +++ b/Orchestrator/.idea/.gitignore @@ -0,0 +1,3 @@ + +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/Orchestrator/.idea/Orchestrator.iml b/Orchestrator/.idea/Orchestrator.iml new file mode 100644 index 00000000..67116063 --- /dev/null +++ b/Orchestrator/.idea/Orchestrator.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Orchestrator/.idea/inspectionProfiles/profiles_settings.xml b/Orchestrator/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/Orchestrator/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Orchestrator/.idea/modules.xml b/Orchestrator/.idea/modules.xml new file mode 100644 index 00000000..17fda74a --- /dev/null +++ b/Orchestrator/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Orchestrator/.idea/vcs.xml b/Orchestrator/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/Orchestrator/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Orchestrator/OpenRPAOrchestratorRun_x32.cmd b/Orchestrator/OpenRPAOrchestratorRun_x32.cmd index b9b01f71..fc9fce1c 100644 --- a/Orchestrator/OpenRPAOrchestratorRun_x32.cmd +++ b/Orchestrator/OpenRPAOrchestratorRun_x32.cmd @@ -1,4 +1,4 @@ cd %~dp0 copy /Y ..\Resources\WPy32-3720\python-3.7.2\python.exe ..\Resources\WPy32-3720\python-3.7.2\OpenRPAOrchestrator.exe -.\..\Resources\WPy32-3720\python-3.7.2\OpenRPAOrchestrator.exe orchestratorMain.py +.\..\Resources\WPy32-3720\python-3.7.2\OpenRPAOrchestrator.exe Orchestrator.py pause >nul \ No newline at end of file diff --git a/Orchestrator/OpenRPAOrchestratorRun_x64.cmd b/Orchestrator/OpenRPAOrchestratorRun_x64.cmd index e4c0fcf1..64b73cd1 100644 --- a/Orchestrator/OpenRPAOrchestratorRun_x64.cmd +++ b/Orchestrator/OpenRPAOrchestratorRun_x64.cmd @@ -1,4 +1,4 @@ cd %~dp0 copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPAOrchestrator.exe -.\..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPAOrchestrator.exe orchestratorMain.py +.\..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPAOrchestrator.exe Orchestrator.py pause >nul \ No newline at end of file diff --git a/Orchestrator/orchestratorMain.py b/Orchestrator/Orchestrator.py similarity index 80% rename from Orchestrator/orchestratorMain.py rename to Orchestrator/Orchestrator.py index 355972c0..124369d7 100644 --- a/Orchestrator/orchestratorMain.py +++ b/Orchestrator/Orchestrator.py @@ -6,9 +6,9 @@ import codecs import os import signal import pdb -import orchestratorServer -import orchestratorTimer -import orchestratorProcessor +import Server +import Timer +import Processor import logging from Settings import Settings @@ -18,43 +18,29 @@ if not os.path.exists("Reports"): os.makedirs("Reports") logging.basicConfig(filename="Reports\ReportRun_"+datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")+".log", level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") -lGlobalDict={} -#"JSONConfigurationDict": -#"ActivityLog":[{""}] -#"ActivityLogSchedule" - -lDaemonConfigurationObject=Settings.mDict - #Единый глобальный словарь (За основу взять из Settings.py) global mGlobalDict mGlobalDict = Settings.mDict -orchestratorProcessor.mGlobalDict = mGlobalDict -orchestratorTimer.mGlobalDict = mGlobalDict -orchestratorServer.mGlobalDict = mGlobalDict -orchestratorServer.orchestratorProcessor.mGlobalDict = mGlobalDict +Processor.mGlobalDict = mGlobalDict +Timer.mGlobalDict = mGlobalDict +Timer.Processor.mGlobalDict = mGlobalDict +Server.mGlobalDict = mGlobalDict +Server.Processor.mGlobalDict = mGlobalDict #Инициализация настроечных параметров -lDaemonLoopSeconds=lDaemonConfigurationObject["Scheduler"]["ActivityTimeCheckLoopSeconds"] +lDaemonLoopSeconds=mGlobalDict["Scheduler"]["ActivityTimeCheckLoopSeconds"] lDaemonActivityLogDict={} #Словарь отработанных активностей, ключ - кортеж (, , , ) lDaemonStartDateTime=datetime.datetime.now() -#Инициализация globalDict -lGlobalDict["JSONConfigurationDict"]=lDaemonConfigurationObject -lGlobalDict["ActivityLogSchedule"]=lDaemonActivityLogDict -lGlobalDict["ActivityLogScheduleList"]=[] -lGlobalDict["GlobalDict"]=mGlobalDict - -orchestratorServer.mActivityLogDict = lDaemonActivityLogDict - #Инициализация сервера -lThreadServer = orchestratorServer.RobotDaemonServer("ServerThread",lGlobalDict) +lThreadServer = Server.RobotDaemonServer("ServerThread", mGlobalDict) lThreadServer.start() #Вечный цикл while True: lCurrentDateTime=datetime.datetime.now() #Циклический обход правил lFlagSearchActivityType=True - for lIndex, lItem in enumerate(lDaemonConfigurationObject["Scheduler"]["ActivityTimeList"]): + for lIndex, lItem in enumerate(mGlobalDict["Scheduler"]["ActivityTimeList"]): #Проверка дней недели, в рамках которых можно запускать активность lItemWeekdayList=lItem.get("WeekdayList",[0,1,2,3,4,5,6]) if lCurrentDateTime.weekday() in lItemWeekdayList: @@ -81,7 +67,7 @@ while True: #Запись в массив отработанных активностей lDaemonActivityLogDict[(lIndex,lActivityDateTime)]={"ActivityStartDateTime":lCurrentDateTime} #Запустить процесс - orchestratorProcessor.ActivityListOrDict(lItem["Activity"]) + Processor.ActivityListOrDict(lItem["Activity"]) ####################################################################### #Banch 2 - if TimeHH:MMStart, TimeHH:MMStop, ActivityIntervalSeconds ####################################################################### @@ -100,6 +86,6 @@ while True: #Запись в массив отработанных активностей lDaemonActivityLogDict[(lIndex,lActivityDateTime)]={"ActivityStartDateTime":lCurrentDateTime} #Запуск циклической процедуры - orchestratorTimer.activityLoopStart(lItem["ActivityIntervalSeconds"],lActivityTimeEndDateTime, lItem["Activity"]) + Timer.activityLoopStart(lItem["ActivityIntervalSeconds"], lActivityTimeEndDateTime, lItem["Activity"]) #Уснуть до следующего прогона time.sleep(lDaemonLoopSeconds) \ No newline at end of file diff --git a/Orchestrator/orchestratorProcessor.py b/Orchestrator/Processor.py similarity index 100% rename from Orchestrator/orchestratorProcessor.py rename to Orchestrator/Processor.py diff --git a/Orchestrator/orchestratorServer.py b/Orchestrator/Server.py similarity index 77% rename from Orchestrator/orchestratorServer.py rename to Orchestrator/Server.py index d2cecba1..e3f4b52d 100644 --- a/Orchestrator/orchestratorServer.py +++ b/Orchestrator/Server.py @@ -8,7 +8,7 @@ import os import PIL from PIL import ImageGrab from threading import Thread -import orchestratorProcessor +import Processor import importlib import pdb import imp @@ -26,46 +26,15 @@ def SaveScreenshot(inFilePath): # save image file #lScreenshot.save('screenshot.png') -#Глобальные переменные -global mActivityLogDict - #inGlobalDict # "JSONConfigurationDict": class RobotDaemonServer(Thread): def __init__(self,name,inGlobalDict): Thread.__init__(self) self.name = name - global mJSONConfigurationDict - mJSONConfigurationDict=inGlobalDict["JSONConfigurationDict"] - #Перенос переменной в orchestratorProcessor - orchestratorProcessor.mGlobalDict=inGlobalDict["GlobalDict"] - #Init other functions - #TODO do module init once when run - #lRenderFunctionsRobotList=mJSONConfigurationDict["ControlPanelDict"]["RobotList"] - #for lItem in lRenderFunctionsRobotList: - #lModuleImportName = lItem.get("RenderFunctionModuleSubfolderName","") - #f = None - #filename = None - #description = None - #if lModuleImportName!="": - # lModuleImportName = f'{lItem["RenderFunctionModuleSubfolderName"]}.{lItem["RenderFunctionModuleName"]}' - # f, filename, description = imp.find_module(lModuleImportName) - #else: - # lModuleImportName = lItem["RenderFunctionModuleName"] - # f, filename, description = imp.find_module(lModuleImportName) - #Подключить модуль для вызова - #importlib.import_module(lModuleImportName) - #pdb.set_trace() - #import imp - #f, filename, description = imp.find_module(lModuleImportName) - #example_package = imp.load_module(lModuleImportName, f, filename, description) - #print('Package:', example_package) - #f.close() - #print(globals()) - #print(lModuleImportName) def run(self): inServerAddress=""; - inPort = mJSONConfigurationDict["Server"]["ListenPort"]; + inPort = mGlobalDict["Server"]["ListenPort"]; print('starting server..., port:'+str(inPort)+" inAddress:"+inServerAddress) # Server settings # Choose port 8080, for port 80, which is normally used for a http server, you need root access @@ -128,7 +97,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): self.send_header('Content-type','application/json') self.end_headers() # Send message back to client - message = json.dumps(mJSONConfigurationDict) + message = json.dumps(mGlobalDict) # Write content as utf-8 data self.wfile.write(bytes(message, "utf8")) if self.path == '/Monitor/ControlPanelDictGet': @@ -139,7 +108,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): self.end_headers() #Create result JSON lResultJSON={"RenderRobotList":[]} - lRenderFunctionsRobotList=mJSONConfigurationDict["ControlPanelDict"]["RobotList"] + lRenderFunctionsRobotList=mGlobalDict["ControlPanelDict"]["RobotList"] for lItem in lRenderFunctionsRobotList: #Подключить модуль для вызова #print(globals()) @@ -152,11 +121,10 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): #Найти функцию lFunction=getattr(lModule,lItem["RenderFunctionName"]) #Выполнить вызов и записать результат - lItemResultDict=lFunction(mJSONConfigurationDict) + lItemResultDict=lFunction(mGlobalDict) #RunFunction lResultJSON["RenderRobotList"].append(lItemResultDict) # Send message back to client - #print(mJSONConfigurationDict) message = json.dumps(lResultJSON) # Write content as utf-8 data self.wfile.write(bytes(message, "utf8")) @@ -164,8 +132,8 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): if self.path.lower().startswith('/filemanager/'): lFileURL=self.path[13:] # check if file in FileURL - File Path Mapping Dict - if lFileURL.lower() in mJSONConfigurationDict["FileManager"]["FileURLFilePathDict"]: - self.SendResponseContentTypeFile('application/octet-stream',mJSONConfigurationDict["FileManager"]["FileURLFilePathDict"][lFileURL]) + if lFileURL.lower() in mGlobalDict["FileManager"]["FileURLFilePathDict"]: + self.SendResponseContentTypeFile('application/octet-stream',mGlobalDict["FileManager"]["FileURLFilePathDict"][lFileURL]) # POST def do_POST(self): #Централизованная функция получения запросов/отправки @@ -183,7 +151,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): self.send_header('Content-type','application/json') self.end_headers() # Send message back to client - message = json.dumps(orchestratorProcessor.ActivityListOrDict(lInputObject)) + message = json.dumps(Processor.ActivityListOrDict(lInputObject)) # Write content as utf-8 data self.wfile.write(bytes(message, "utf8")) return diff --git a/Orchestrator/orchestratorTimer.py b/Orchestrator/Timer.py similarity index 95% rename from Orchestrator/orchestratorTimer.py rename to Orchestrator/Timer.py index 77ec002d..782d1c81 100644 --- a/Orchestrator/orchestratorTimer.py +++ b/Orchestrator/Timer.py @@ -3,7 +3,7 @@ import datetime import subprocess import importlib import logging -import orchestratorProcessor +import Processor global mGlobalDict @@ -39,7 +39,7 @@ def activityLoopExecution(inLoopTimeEndDateTime, inActivity): lResultGoLoop=True lCurrentDateTime=datetime.datetime.now() #Запустить актитвость через процессор (orchestratorProcessor) - orchestratorProcessor.ActivityListOrDict(inActivity) + Processor.ActivityListOrDict(inActivity) #Выключить таймер, если время наступило if lCurrentDateTime>=inLoopTimeEndDateTime: lResultGoLoop=False diff --git a/Orchestrator/todo.txt b/Orchestrator/todo.txt index 6afdd76d..5ff6b92d 100644 --- a/Orchestrator/todo.txt +++ b/Orchestrator/todo.txt @@ -1,4 +1,4 @@ -1. orchestrator Orchestrator/ OrchestratorMain > Orchestrator -2. orchestratorProcessor -3. inConfiguration. - -4. orchestratorProcessor +1. [+] orchestrator Orchestrator/ OrchestratorMain > Orchestrator +2. [+] orchestratorProcessor +3. [+] inConfiguration. - +4. [+] orchestratorProcessor diff --git a/v1.0.4 b/v1.0.5 similarity index 100% rename from v1.0.4 rename to v1.0.5