|
|
|
@ -14,13 +14,13 @@ def SaveScreenshot(inFilePath):
|
|
|
|
|
lScreenshot = ImageGrab.grab()
|
|
|
|
|
# save image file
|
|
|
|
|
lScreenshot.save('screenshot.png')
|
|
|
|
|
|
|
|
|
|
mJSONConfigurationDict={}
|
|
|
|
|
class RobotDaemonServer(Thread):
|
|
|
|
|
self.mJSONConfigurationDict={};
|
|
|
|
|
def __init__(self,name,inJSONConfigurationDict):
|
|
|
|
|
Thread.__init__(self)
|
|
|
|
|
self.name = name
|
|
|
|
|
self.mJSONConfigurationDict=inJSONConfigurationDict
|
|
|
|
|
global mJSONConfigurationDict
|
|
|
|
|
mJSONConfigurationDict=inJSONConfigurationDict
|
|
|
|
|
def run(self,inServerAddress="127.0.0.1",inPort=8081):
|
|
|
|
|
print('starting server...')
|
|
|
|
|
# Server settings
|
|
|
|
@ -34,6 +34,9 @@ class RobotDaemonServer(Thread):
|
|
|
|
|
# HTTPRequestHandler class
|
|
|
|
|
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
#ResponseContentTypeFile
|
|
|
|
|
def Config(self,inJSONConfigurationDict):
|
|
|
|
|
self.mJSONConfigurationDict=inJSONConfigurationDict
|
|
|
|
|
#ResponseContentTypeFile
|
|
|
|
|
def SendResponseContentTypeFile(self,inContentType,inFilePath):
|
|
|
|
|
# Send response status code
|
|
|
|
|
self.send_response(200)
|
|
|
|
@ -68,33 +71,27 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/favicon.ico':
|
|
|
|
|
self.SendResponseContentTypeFile('image/x-icon',"..\\..\\favicon.ico")
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/Handlebars/handlebars-v4.1.2.js':
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript',"..\\..\\3rdParty\\Handlebars\\handlebars-v4.1.2.js")
|
|
|
|
|
#Получить скриншот
|
|
|
|
|
|
|
|
|
|
if self.path.split("?")[0] == '/GetScreenshot':
|
|
|
|
|
#Сохранить файл на диск
|
|
|
|
|
SaveScreenshot("Screenshot.png")
|
|
|
|
|
self.SendResponseContentTypeFile('image/png',"Screenshot.png")
|
|
|
|
|
|
|
|
|
|
#Action ObjectInspector GetObjectList
|
|
|
|
|
if self.path == '/ObjectDetector/JSONGetWindowList':
|
|
|
|
|
#ReadRequest
|
|
|
|
|
#lInputByteArray=self.rfile.read()
|
|
|
|
|
#print(str(len(os.stat(self.rfile).st_size)))
|
|
|
|
|
#Monitor
|
|
|
|
|
if self.path == '/Monitor/JSONDaemonListGet':
|
|
|
|
|
# Send response status code
|
|
|
|
|
self.send_response(200)
|
|
|
|
|
# Send headers
|
|
|
|
|
self.send_header('Content-type','application/json')
|
|
|
|
|
self.end_headers()
|
|
|
|
|
# Send message back to client
|
|
|
|
|
#{'functionName':'', 'argsArray':[]}
|
|
|
|
|
lRequestObject={'functionName':'ElementGetChildElementList','argsArray':[]}
|
|
|
|
|
#Отправить запрос в дочерний процесс, который отвечает за работу с Windows окнами
|
|
|
|
|
#ProcessChildSendObject(p,lRequestObject)
|
|
|
|
|
#Получить ответ от дочернего процесса
|
|
|
|
|
#lResponseObject=ProcessChildReadWaitObject(p)
|
|
|
|
|
message = json.dumps(lResponseObject)
|
|
|
|
|
message = json.dumps(mJSONConfigurationDict)
|
|
|
|
|
# Write content as utf-8 data
|
|
|
|
|
self.wfile.write(bytes(message, "utf8"))
|
|
|
|
|
self.wfile.write(bytes(message, "utf8"))
|
|
|
|
|
|
|
|
|
|
# POST
|
|
|
|
|
def do_POST(self):
|
|
|
|
|
#Action ObjectInspector GetObjectList
|
|
|
|
|