- Test URL "/pyOpenRPA/ServerData"

- Create new support - CP def can return {"CPKeyStr":{"HTMLStr":"", DataDict:{}}}
- Create CP 2 HTML generator for the backward compatibility
dev-linux
Ivan Maslov 4 years ago
parent 2a36bc8e70
commit a2eab2389a

@ -14,7 +14,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -37,84 +37,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"2020-10-11 00:32:27,869 - Orchestrator - INFO - Link the gSettings in submodules\n",
"2020-10-11 00:32:27,878 - Orchestrator - WARNING - Backward compatibility (v1.1.13 to v1.1.14): Add default 'Autocleaner' structure\n",
"2020-10-11 00:32:27,880 - Orchestrator - WARNING - Backward compatibility (v1.1.13 to v1.1.14): Add default 'Client' structure\n",
"2020-10-11 00:32:27,882 - Orchestrator - WARNING - Backward compatibility (v1.1.13 to v1.1.14): Add default 'Server' > 'RequestTimeoutSecFloat' property\n",
"2020-10-11 00:32:27,883 - Orchestrator - WARNING - Backward compatibility (v1.1.13 to v1.1.14): Add default 'OrchestratorStart' > 'DefSettingsUpdatePathList' property list\n",
"2020-10-11 00:32:27,886 - Orchestrator - WARNING - Backward compatibility (v1.1.20 to v1.2.0): Remove old structure 'Processor'\n",
"2020-10-11 00:32:27,888 - Orchestrator - WARNING - Backward compatibility (v1.1.20 to v1.2.0): Create new structure 'ProcessorDict'\n",
"2020-10-11 00:32:27,893 - Orchestrator - INFO - Server init. Listen URL: , Listen port: 80\n",
"2020-10-11 00:32:27,893 - Orchestrator - INFO - Web server has been started\n",
"2020-10-11 00:32:27,932 - Orchestrator - INFO - Robot Screen active has been started\n",
"2020-10-11 00:32:27,937 - Orchestrator - INFO - Robot RDP active has been started\n",
"2020-10-11 00:32:27,940 - Orchestrator - INFO - Autocleaner thread has been started\n",
"2020-10-11 00:32:27,942 - Orchestrator - INFO - Orchestrator start activity run\n",
"2020-10-11 00:32:27,944 - Orchestrator - INFO - Scheduler loop start\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"----------------------------------------\n",
"Exception happened during processing of request from ('127.0.0.1', 57154)\n",
"Traceback (most recent call last):\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\socketserver.py\", line 650, in process_request_thread\n",
" self.finish_request(request, client_address)\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Server.py\", line 476, in finish_request\n",
" HTTPServer.finish_request(self, request, client_address)\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\socketserver.py\", line 360, in finish_request\n",
" self.RequestHandlerClass(request, client_address, self)\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\socketserver.py\", line 720, in __init__\n",
" self.handle()\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\http\\server.py\", line 426, in handle\n",
" self.handle_one_request()\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\http\\server.py\", line 414, in handle_one_request\n",
" method()\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Server.py\", line 336, in do_GET\n",
" lAuthenticateDict = AuthenticateVerify(self)\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Server.py\", line 73, in AuthenticateVerify\n",
" \"Password\": lPassword\n",
" File \"..\\pyOpenRPA\\Orchestrator\\ProcessorOld.py\", line 94, in Activity\n",
" lItem[\"Result\"] = Processor.ActivityListExecute(inGSettings = gSettingsDict, inActivityList = [inActivity])\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Processor.py\", line 32, in ActivityListExecute\n",
" if callable(lActivityItem[\"Def\"]): # CHeck if def is callable\n",
"KeyError: 'Def'\n",
"----------------------------------------\n",
"----------------------------------------\n",
"Exception happened during processing of request from ('127.0.0.1', 57158)\n",
"Traceback (most recent call last):\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\socketserver.py\", line 650, in process_request_thread\n",
" self.finish_request(request, client_address)\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Server.py\", line 476, in finish_request\n",
" HTTPServer.finish_request(self, request, client_address)\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\socketserver.py\", line 360, in finish_request\n",
" self.RequestHandlerClass(request, client_address, self)\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\socketserver.py\", line 720, in __init__\n",
" self.handle()\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\http\\server.py\", line 426, in handle\n",
" self.handle_one_request()\n",
" File \"C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\http\\server.py\", line 414, in handle_one_request\n",
" method()\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Server.py\", line 336, in do_GET\n",
" lAuthenticateDict = AuthenticateVerify(self)\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Server.py\", line 73, in AuthenticateVerify\n",
" \"Password\": lPassword\n",
" File \"..\\pyOpenRPA\\Orchestrator\\ProcessorOld.py\", line 94, in Activity\n",
" lItem[\"Result\"] = Processor.ActivityListExecute(inGSettings = gSettingsDict, inActivityList = [inActivity])\n",
" File \"..\\pyOpenRPA\\Orchestrator\\Processor.py\", line 32, in ActivityListExecute\n",
" if callable(lActivityItem[\"Def\"]): # CHeck if def is callable\n",
"KeyError: 'Def'\n",
"----------------------------------------\n"
]
}
],
"source": [ "source": [
"from pyOpenRPA.Orchestrator import Orchestrator # Import orchestrator main\n", "from pyOpenRPA.Orchestrator import Orchestrator # Import orchestrator main\n",
"Orchestrator.Orchestrator(inGSettings=gSettings) # Call the orchestrator" "Orchestrator.Orchestrator(inGSettings=gSettings) # Call the orchestrator"
@ -122,10 +45,33 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
"import os\n",
"t=os.system(\"echo 2313\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",

@ -9,6 +9,7 @@ import uuid # generate UUID4
import time # sleep functions import time # sleep functions
import datetime # datetime functions import datetime # datetime functions
import threading # Multi-threading import threading # Multi-threading
from .Web import Basic
# Generate CP # Generate CP
# Return {"Key":{"",""}} # Return {"Key":{"",""}}
@ -38,7 +39,12 @@ def HiddenCPDictGenerate(inRequest, inGSettings):
lItemResultDict = lItem["RenderFunction"]() lItemResultDict = lItem["RenderFunction"]()
# RunFunction # RunFunction
# lResultJSON["RenderRobotList"].append(lItemResultDict) # lResultJSON["RenderRobotList"].append(lItemResultDict)
lCPDict[lItem["KeyStr"]] = lItemResultDict # Backward compatibility up to 1.2.0 - call HTML generator if result has no "HTMLStr"
if "HTMLStr" in lItemResultDict or "DataDict" in lItemResultDict:
lCPDict[lItem["KeyStr"]] = lItemResultDict # new version
else:
# Call backward compatibility HTML generator
lCPDict[lItem["KeyStr"]] = {"HTMLStr": Basic.HTMLControlPanelBC(inCPDict=lItemResultDict), "DataDict":{}}
except Exception as e: except Exception as e:
if lL: lL.exception(f"Error in control panel. CP item {lItem}. Exception is below") if lL: lL.exception(f"Error in control panel. CP item {lItem}. Exception is below")
return lCPDict return lCPDict
@ -61,7 +67,8 @@ def HiddenRDPDictGenerate(inRequest, inGSettings):
return lRDPDict return lRDPDict
#v1.2.0 Send data container to the client from the server #v1.2.0 Send data container to the client from the server
# /pyOpenRPA/ServerData return {"HashStr" , "ServerDataDict"} # /pyOpenRPA/ServerData return {"HashStr" , "ServerDataDict": {"CPKeyStr":{"HTMLStr":"", DataDict:{}}}}
# Client: mGlobal.pyOpenRPA.ServerDataHashStr # Client: mGlobal.pyOpenRPA.ServerDataHashStr
# Client: mGlobal.pyOpenRPA.ServerDataDict # Client: mGlobal.pyOpenRPA.ServerDataDict
def pyOpenRPA_ServerData(inRequest,inGSettings): def pyOpenRPA_ServerData(inRequest,inGSettings):
@ -73,7 +80,6 @@ def pyOpenRPA_ServerData(inRequest,inGSettings):
lInputByteArray = inRequest.rfile.read(lInputByteArrayLength) lInputByteArray = inRequest.rfile.read(lInputByteArrayLength)
# Превращение массива байт в объект # Превращение массива байт в объект
lValueStr = (lInputByteArray.decode('utf8')) lValueStr = (lInputByteArray.decode('utf8'))
# Generate ServerDataDict # Generate ServerDataDict
lFlagDoGenerateBool = True lFlagDoGenerateBool = True
while lFlagDoGenerateBool: while lFlagDoGenerateBool:
@ -92,6 +98,11 @@ def pyOpenRPA_ServerData(inRequest,inGSettings):
time.sleep(inGSettings["Client"]["Session"]["ControlPanelRefreshIntervalSecFloat"]) time.sleep(inGSettings["Client"]["Session"]["ControlPanelRefreshIntervalSecFloat"])
# Return the result if Hash is changed # Return the result if Hash is changed
lResult = {"HashStr": lServerDataHashStr, "ServerDataDict": lServerDataDict} lResult = {"HashStr": lServerDataHashStr, "ServerDataDict": lServerDataDict}
inResponseDict = inRequest.OpenRPAResponseDict
# Send message back to client
message = json.dumps(lResult)
# Write content as utf-8 data
inResponseDict["Body"] = bytes(message, "utf8")
return lResult return lResult

@ -23,4 +23,56 @@ def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None):
if inColorStr: lCSSStyleStr=f"style=\"color:{inColorStr}\"" if inColorStr: lCSSStyleStr=f"style=\"color:{inColorStr}\""
inJSOnClickStr= JSEscapeForHTMLInline(inJSStr=inJSOnClickStr) # Escape some symbols for the inline JS inJSOnClickStr= JSEscapeForHTMLInline(inJSStr=inJSOnClickStr) # Escape some symbols for the inline JS
lResult=f"<a {lCSSStyleStr} onclick=\"{inJSOnClickStr}\">{inTitleStr}</a>" lResult=f"<a {lCSSStyleStr} onclick=\"{inJSOnClickStr}\">{inTitleStr}</a>"
return lResult return lResult
# HTML Generator for the CP up to v.1.2.0
def HTMLControlPanelBC(inCPDict):
# FooterButtonX2List generation
lFooterButtonX2Str = ""
for lItem in inCPDict["FooterButtonX2List"]:
lFooterButtonX2Str+=f'<div class="ui basic {lItem.get("Color","")} button" onclick="{lItem.get("OnClick","")}">{lItem.get("Text","")}</div>'
# FooterButtonX1List generation
lFooterButtonX1Str = ""
for lItem in inCPDict["FooterButtonX1List"]:
lFooterButtonX1Str+=f'<div class="ui basic {lItem.get("Color","")} button" onclick="{lItem.get("OnClick","")}">{lItem.get("Text","")}</div>'
# BodyKeyValue generation
lBodyKeyValueStr = ""
for lItem in inCPDict["BodyKeyValueList"]:
lBodyKeyValueStr+=f"<li>{lItem['Key']}: {lItem['Value']}</li>"
# Generate consolidated string
lResultHTMLStr = f"""
<div class="card">
<div class="content">
<div class="right floated mini ui ">
{inCPDict['HeaderRightText']}
</div>
<div class="header">
{inCPDict['HeaderLeftText']}
</div>
<div class="meta">
{inCPDict['SubheaderText']}
</div>
<div class="description">
<ul style="padding-inline-start:16px;margin:0px">
{lBodyKeyValueStr}
</ul>
</div>
</div>
<div class="extra content">
{inCPDict['FooterText']}
</div>
<div class="extra content">
<div class="ui two buttons">
{lFooterButtonX2Str}
</div>
<div class="ui horizontal divider">Add. controls</div>
<div class="ui one buttons">
{lFooterButtonX1Str}
</div>
</div>
</div>
"""
return lResultHTMLStr

@ -1,4 +1,5 @@
var mGlobal={} var mGlobal={}
mGlobal.pyOpenRPA = {}
window.onload=function() { window.onload=function() {
//document.cookie = "SessionGUIDStr=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; //document.cookie = "SessionGUIDStr=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
//Render existing data //Render existing data
@ -347,8 +348,64 @@ $(document).ready(function() {
} }
} }
} }
/// v1.2.0 pyOpenRPA ServerData
mGlobal.pyOpenRPA.ServerDataDict = null
mGlobal.pyOpenRPA.ServerDataHashStr = ""
mGlobal.pyOpenRPA.ServerDataRefreshDef_TechnicalRender = function()
{
lResponseJSON = mGlobal.pyOpenRPA.ServerDataDict
if (lResponseJSON!= null) {
/// New version of control panels
lHTMLCode = '<div class="ui cards">'
for (var lKeyStr in lResponseJSON["CPDict"]){
lCPDict = lResponseJSON["CPDict"][lKeyStr]
/// Render HTML
if ("HTMLStr" in lCPDict) {
lHTMLCode+=lCPDict["HTMLStr"]
}
}
lHTMLCode += '</div>'
///Прогрузить новую таблицу
$(".openrpa-control-panel").html(lHTMLCode)
}
}
mGlobal.pyOpenRPA.ServerDataRefreshDef=function() {
try {
$.ajax({
type: "POST",
headers: {},
url: 'pyOpenRPA/ServerData',
data: mGlobal.pyOpenRPA.ServerDataHashStr,
success: function(lData,l2,l3) {
try {
var lResponseJSON=JSON.parse(lData)
mGlobal.pyOpenRPA.ServerDataDict = lResponseJSON["ServerDataDict"]
mGlobal.pyOpenRPA.ServerDataHashStr = lResponseJSON["HashStr"]
mGlobal.pyOpenRPA.ServerDataRefreshDef_TechnicalRender()
}
catch(error) {
}
mGlobal.pyOpenRPA.ServerDataRefreshDef() // recursive
},
dataType: "text",
error: function(jqXHR, textStatus, errorThrown ) {
sleep(3000)
mGlobal.pyOpenRPA.ServerDataRefreshDef() // recursive
}
});
}
catch(error) {
sleep(3000)
mGlobal.pyOpenRPA.ServerDataRefreshDef() // recursive
}
}
/////////////////////////////////////////////////////////////
mGlobal.Monitor.mDatasetLast = null mGlobal.Monitor.mDatasetLast = null
mGlobal.Monitor.fControlPanelRefresh=function() { mGlobal.fControlPanelRefresh=function() {
try { try {
//var XHR = new XMLHttpRequest(); //var XHR = new XMLHttpRequest();
//XHR.setRequestHeader("Cookies",document.cookie) //XHR.setRequestHeader("Cookies",document.cookie)
@ -385,6 +442,7 @@ $(document).ready(function() {
} }
//mGlobal.Monitor.fControlPanelRefresh() // recursive //mGlobal.Monitor.fControlPanelRefresh() // recursive
} }
mGlobal.Test=function() { mGlobal.Test=function() {
///Обнулить таблицу ///Обнулить таблицу
lData = [ lData = [
@ -723,5 +781,10 @@ $(document).ready(function() {
//Main sub //Main sub
mGlobal.OrchestratorModelUpdate() // Cal the update orchestrator model mGlobal.OrchestratorModelUpdate() // Cal the update orchestrator model
mGlobal.Monitor.fControlPanelRefresh() //mGlobal.Monitor.fControlPanelRefresh()
/// v1.2.0 pyOpenRPA Init defs
mGlobal.pyOpenRPA.ServerDataRefreshDef() // Init the refresh data def from server side
}); });

@ -33,7 +33,9 @@
- - def JSEscapeForHTMLInline(inJSStr): # Escape JS to the safe JS for the inline JS in HTML tags ATTENTION! Use it only if want to paste JS into HTML tag - not in <script> - - def JSEscapeForHTMLInline(inJSStr): # Escape JS to the safe JS for the inline JS in HTML tags ATTENTION! Use it only if want to paste JS into HTML tag - not in <script>
- - def HTMLLinkURL(inURLStr, inTitleStr=None, inColorStr=None): # Generate HTML code of the simple URL link by the URL - - def HTMLLinkURL(inURLStr, inTitleStr=None, inColorStr=None): # Generate HTML code of the simple URL link by the URL
- - def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None): # Generate HTML code of the simple URL link by the JS when onclick - - def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None): # Generate HTML code of the simple URL link by the JS when onclick
- Add URL "/pyOpenRPA/ServerData" - consolidated function - Add URL "/pyOpenRPA/ServerData" - consolidated function - in test
- Create new support - CP def can return {"CPKeyStr":{"HTMLStr":"", DataDict:{}}}
- Create CP 2 HTML generator for the backward compatibility
[1.1.0] [1.1.0]
After 2 month test prefinal with new improovements (+RobotRDPActive in Orchestrator + Easy ControlPanelTemplate) After 2 month test prefinal with new improovements (+RobotRDPActive in Orchestrator + Easy ControlPanelTemplate)
Beta before 1.1.0 (new way of OpenRPA with improvements. Sorry, but no backward compatibility)/ Backward compatibility will start from 1.0.1 Beta before 1.1.0 (new way of OpenRPA with improvements. Sorry, but no backward compatibility)/ Backward compatibility will start from 1.0.1

Loading…
Cancel
Save