#OrchestratorGlobalDictAnywhere #NeedToTestChangeInMainAndCheckInProcessor

dev-linux
Ivan Maslov 6 years ago
parent 3245a7f17d
commit d7c3a56334

@ -8,6 +8,11 @@ import signal
import pdb
import orchestratorServer
lGlobalDict={}
#"JSONConfigurationDict":<JSON>
#"ActivityLog":[{""}]
#"ActivityLogSchedule"
#Чтение конфигурации
lDaemonConfigurationFile = codecs.open("orchestratorConfiguration.json", "r","utf_8_sig")
lDaemonConfigurationJSONString = lDaemonConfigurationFile.read()
@ -16,15 +21,20 @@ lDaemonConfigurationFile.close()
#Преобразование в JSON
lDaemonConfigurationObject=json.loads(lDaemonConfigurationJSONString)
#Инициализация настроечных параметров
lDaemonLoopSeconds=lDaemonConfigurationObject["loopSeconds"]
lDaemonActivityLogDict={} #Словарь отработанных активностей, ключ - кортеж (<activityType>, <datetime>, <processPath || processName>, <processArgs>)
lDaemonStartDateTime=datetime.datetime.now()
#Инициализация globalDict
lGlobalDict["JSONConfigurationDict"]=lDaemonConfigurationObject
lGlobalDict["ActivityLogSchedule"]=lDaemonActivityLogDict
orchestratorServer.mActivityLogDict = lDaemonActivityLogDict
#Инициализация сервера
lThreadServer = orchestratorServer.RobotDaemonServer("ServerThread",lDaemonConfigurationObject)
lThreadServer = orchestratorServer.RobotDaemonServer("ServerThread",lGlobalDict)
lThreadServer.start()
#Вечный цикл
while True:

@ -1,6 +1,8 @@
import datetime
import http.client
import json
#Глобальная переменная - все глобальные значения программы
global mGlobalDict
#{
# actionList:
# [
@ -13,7 +15,9 @@ import json
# ]
#
#}
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":[]}

@ -9,6 +9,7 @@ import PIL
from PIL import ImageGrab
from threading import Thread
import orchestratorProcessor
def SaveScreenshot(inFilePath):
# grab fullscreen
lScreenshot = ImageGrab.grab()
@ -18,13 +19,17 @@ def SaveScreenshot(inFilePath):
#Глобальные переменные
global mActivityLogDict
mJSONConfigurationDict={}
#inGlobalDict
# "JSONConfigurationDict":<JSON>
class RobotDaemonServer(Thread):
def __init__(self,name,inJSONConfigurationDict):
def __init__(self,name,inGlobalDict):
Thread.__init__(self)
self.name = name
global mJSONConfigurationDict
mJSONConfigurationDict=inJSONConfigurationDict
mJSONConfigurationDict=inGlobalDict["JSONConfigurationDict"]
#Перенос переменной в orchestratorProcessor
orchestratorProcessor.mGlobalDict=inGlobalDict
def run(self,inServerAddress="127.0.0.1",inPort=8081):
print('starting server...')
# Server settings
@ -111,7 +116,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
message = json.dumps(robotDaemonProcessor.ProcessingRun(lInputObject))
message = json.dumps(orchestratorProcessor.ProcessingRun(lInputObject))
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
return

Loading…
Cancel
Save