You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Orchestrator/orchestratorProcessor.py

50 lines
2.2 KiB

import datetime
import http.client
import json
import pdb
#Глобальная переменная - все глобальные значения программы
global mGlobalDict
#{
# actionList:
# [
# {
# type: <RemoteMachineProcessingRun>,
# host: <localhost>,
# port: <port>,
# bodyObject: <object dict, int, str, list>
# },
# {
# type: <ActivityLogScheduleListGet>
# }
# ]
#
#}
def ProcessingRun(inConfigurationDict):
#print(mGlobalDict)
lDateTimeString=datetime.datetime.strftime(datetime.datetime.now(),"%Y.%m.%d %H:%M:%S::%f")
lResult={"dateTime":lDateTimeString, "state":"connected", "actionListResult":[]}
for lItem in inConfigurationDict["actionList"]:
#Добавить входные значения
lResult["actionListResult"].append({"inArgs":lItem})
#Обработка запроса на отправку команды на удаленную машину
if lItem["type"]=="RemoteMachineProcessingRun":
lHTTPConnection = http.client.HTTPConnection(lItem["host"], lItem["port"], timeout=5)
try:
lHTTPConnection.request("POST","/ProcessingRun",json.dumps(lItem["bodyObject"]))
except Exception as e:
#Объединение словарей
lResult["actionListResult"][-1] = {**lResult["actionListResult"][-1], **{"state":"disconnected","errorMessage":str(e)}}
#lResult["actionListResult"][-1].join({"state":"disconnected","errorMessage":str(e)})
else:
lHTTPResponse=lHTTPConnection.getresponse()
lHTTPResponseByteArray=lHTTPResponse.read()
lResult["actionListResult"][-1] = {**lResult["actionListResult"][-1], **json.loads(lHTTPResponseByteArray.decode('utf8'))}
#Обработка команды ActivityLogScheduleListGet
if lItem["type"]=="ActivityLogScheduleListGet":
#pdb.set_trace()
lResult["actionListResult"][-1] = {**lResult["actionListResult"][-1], **{"result":mGlobalDict["ActivityLogScheduleList"]}}
#Вернуть результат
return lResult