|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
|
|
|
import json
|
|
|
|
|
from threading import Thread
|
|
|
|
|
import Processor
|
|
|
|
|
from . import Processor
|
|
|
|
|
import importlib
|
|
|
|
|
import pdb
|
|
|
|
|
import base64
|
|
|
|
|
import uuid
|
|
|
|
|
import datetime
|
|
|
|
|
import os #for path operations
|
|
|
|
|
from http import cookies
|
|
|
|
|
from desktopmagic.screengrab_win32 import (
|
|
|
|
|
getDisplayRects, saveScreenToBmp, saveRectToBmp, getScreenAsImage,
|
|
|
|
@ -143,30 +144,31 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
AuthenticateBlock(self)
|
|
|
|
|
#####################################
|
|
|
|
|
else:
|
|
|
|
|
lOrchestratorFolder = "\\".join(__file__.split("\\")[:-1])
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == "/":
|
|
|
|
|
self.SendResponseContentTypeFile('text/html', "Web\\Index.xhtml")
|
|
|
|
|
self.SendResponseContentTypeFile('text/html', os.path.join(lOrchestratorFolder, "Web\\Index.xhtml"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/Semantic-UI-CSS-master/semantic.min.css':
|
|
|
|
|
self.SendResponseContentTypeFile('text/css',"..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.css")
|
|
|
|
|
self.SendResponseContentTypeFile('text/css', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.css"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/Semantic-UI-CSS-master/semantic.min.js':
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript',"..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.js")
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript', os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.js"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/jQuery/jquery-3.1.1.min.js':
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript',"..\\Resources\\Web\\jQuery\\jquery-3.1.1.min.js")
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\jQuery\\jquery-3.1.1.min.js"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/Google/LatoItalic.css':
|
|
|
|
|
self.SendResponseContentTypeFile('font/css',"..\\Resources\\Web\\Google\\LatoItalic.css")
|
|
|
|
|
self.SendResponseContentTypeFile('font/css', os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Google\\LatoItalic.css"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/Semantic-UI-CSS-master/themes/default/assets/fonts/icons.woff2':
|
|
|
|
|
self.SendResponseContentTypeFile('font/woff2',"..\\Resources\\Web\\Semantic-UI-CSS-master\\themes\\default\\assets\\fonts\\icons.woff2")
|
|
|
|
|
self.SendResponseContentTypeFile('font/woff2', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\Semantic-UI-CSS-master\\themes\\default\\assets\\fonts\\icons.woff2"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/favicon.ico':
|
|
|
|
|
self.SendResponseContentTypeFile('image/x-icon',"Web\\favicon.ico")
|
|
|
|
|
self.SendResponseContentTypeFile('image/x-icon', os.path.join(lOrchestratorFolder, "Web\\favicon.ico"))
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
if self.path == '/3rdParty/Handlebars/handlebars-v4.1.2.js':
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript',"..\\Resources\\Web\\Handlebars\\handlebars-v4.1.2.js")
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\Handlebars\\handlebars-v4.1.2.js"))
|
|
|
|
|
#Получить скриншот
|
|
|
|
|
if self.path.split("?")[0] == '/GetScreenshot':
|
|
|
|
|
#Сохранить файл на диск
|
|
|
|
@ -193,18 +195,8 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
lResultJSON={"RenderRobotList":[]}
|
|
|
|
|
lRenderFunctionsRobotList=mGlobalDict["ControlPanelDict"]["RobotList"]
|
|
|
|
|
for lItem in lRenderFunctionsRobotList:
|
|
|
|
|
#Подключить модуль для вызова
|
|
|
|
|
#print(globals())
|
|
|
|
|
lModuleImportName = lItem.get("RenderFunctionModuleSubfolderName","")
|
|
|
|
|
if lModuleImportName!="":
|
|
|
|
|
lModuleImportName = f'{lItem["RenderFunctionModuleSubfolderName"]}.{lItem["RenderFunctionModuleName"]}'
|
|
|
|
|
else:
|
|
|
|
|
lModuleImportName = lItem["RenderFunctionModuleName"]
|
|
|
|
|
lModule=importlib.import_module(lModuleImportName)
|
|
|
|
|
#Найти функцию
|
|
|
|
|
lFunction=getattr(lModule, lItem["RenderFunctionName"])
|
|
|
|
|
#Выполнить вызов и записать результат
|
|
|
|
|
lItemResultDict=lFunction(mGlobalDict)
|
|
|
|
|
lItemResultDict=lItem["RenderFunction"](mGlobalDict)
|
|
|
|
|
#RunFunction
|
|
|
|
|
lResultJSON["RenderRobotList"].append(lItemResultDict)
|
|
|
|
|
# Send message back to client
|
|
|
|
|