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