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.
77 lines
3.5 KiB
77 lines
3.5 KiB
import json
|
|
#Insert in DB
|
|
def SQLInsert(inRequest,inGlobalDict):
|
|
inResponseDict = inRequest.OpenRPAResponseDict
|
|
# Create result JSON
|
|
lResultJSON = {"FlagSQLInsert": False}
|
|
#Read the body
|
|
#ReadRequest
|
|
lInputJSON={}
|
|
if inRequest.headers.get('Content-Length') is not None:
|
|
lInputByteArrayLength = int(inRequest.headers.get('Content-Length'))
|
|
lInputByteArray=inRequest.rfile.read(lInputByteArrayLength)
|
|
print(lInputByteArray.decode('utf8'))
|
|
#Превращение массива байт в объект
|
|
lInputJSON=json.loads(lInputByteArray.decode('utf8'))
|
|
########################################
|
|
print(lInputJSON)
|
|
import sqlite3
|
|
conn = sqlite3.connect(inGlobalDict["SQLite"]["DBPath"])
|
|
c = conn.cursor()
|
|
# Loop for rows
|
|
for lRowItem in lInputJSON:
|
|
my_dict = lRowItem["RowDict"]
|
|
# Insert a row of data
|
|
columns = ', '.join(my_dict.keys())
|
|
placeholders = ':'+', :'.join(my_dict.keys())
|
|
query = f'INSERT INTO {lRowItem["TableName"]} (%s) VALUES (%s)' % (columns, placeholders)
|
|
c.execute(query, my_dict)
|
|
# Save (commit) the changes
|
|
conn.commit()
|
|
# We can also close the connection if we are done with it.
|
|
# Just be sure any changes have been committed or they will be lost.
|
|
conn.close()
|
|
########################################
|
|
# Send message back to client
|
|
message = json.dumps(lResultJSON)
|
|
# Write content as utf-8 data
|
|
inResponseDict["Body"] = bytes(message, "utf8")
|
|
|
|
def GetScreenshot(inRequest,inGlobalDict):
|
|
# Get Screenshot
|
|
def SaveScreenshot(inFilePath):
|
|
# grab fullscreen
|
|
# Save the entire virtual screen as a PNG
|
|
lScreenshot = getScreenAsImage()
|
|
lScreenshot.save('screenshot.png', format='png')
|
|
# lScreenshot = ScreenshotSecondScreen.grab_screen()
|
|
# save image file
|
|
# lScreenshot.save('screenshot.png')
|
|
# Сохранить файл на диск
|
|
SaveScreenshot("Screenshot.png")
|
|
lFileObject = open("Screenshot.png", "rb")
|
|
# Write content as utf-8 data
|
|
inRequest.OpenRPAResponseDict["Body"] = lFileObject.read()
|
|
# Закрыть файловый объект
|
|
lFileObject.close()
|
|
def SettingsUpdate(inGlobalConfiguration):
|
|
import os
|
|
import pyOpenRPA.Orchestrator
|
|
lOrchestratorFolder = "\\".join(pyOpenRPA.Orchestrator.__file__.split("\\")[:-1])
|
|
lURLList = \
|
|
[ #List of available URLs with the orchestrator server
|
|
#{
|
|
# "Method":"GET|POST",
|
|
# "URL": "/index", #URL of the request
|
|
# "MatchType": "", #"BeginWith|Contains|Equal|EqualCase",
|
|
# "ResponseFilePath": "", #Absolute or relative path
|
|
# "ResponseFolderPath": "", #Absolute or relative path
|
|
# "ResponseContentType": "", #HTTP Content-type
|
|
# "ResponseDefRequestGlobal": None #Function with str result
|
|
#}
|
|
#Orchestrator basic dependencies
|
|
{"Method":"POST", "URL": "/", "MatchType": "EqualCase", "ResponseDefRequestGlobal": SQLInsert, "ResponseContentType": "text/html"},
|
|
{"Method":"GET", "URL": "/3rdParty/Semantic-UI-CSS-master/semantic.min.css", "MatchType": "EqualCase", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.css"), "ResponseContentType": "text/css"}
|
|
]
|
|
inGlobalConfiguration["Server"]["URLList"]=inGlobalConfiguration["Server"]["URLList"]+lURLList
|
|
return inGlobalConfiguration |