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