# Add new Handler for the log dump - need to refactoring...!!!!

dev-linux
Ivan Maslov 4 years ago
parent 2942b7cc70
commit bde44722e9

@ -349,3 +349,11 @@ def Update(inGSettings):
if "VersionStr" not in inGSettings: # Create new ProcessorDict structure if "VersionStr" not in inGSettings: # Create new ProcessorDict structure
inGSettings["VersionStr"] = None inGSettings["VersionStr"] = None
if lL: lL.warning(f"Backward compatibility (v1.1.20 to v1.2.0): Create new attribute 'VersionStr'") # Log about compatibility if lL: lL.warning(f"Backward compatibility (v1.1.20 to v1.2.0): Create new attribute 'VersionStr'") # Log about compatibility
if "DumpLogListRefreshIntervalSecFloat" not in inGSettings["Client"]: # Create new ProcessorDict structure
inGSettings["Client"].update({
"DumpLogListRefreshIntervalSecFloat": 5.0, # Duration between updates for the Client
"DumpLogListCountInt": 100, # Set the max row for the dump
"DumpLogList": [], # Will be filled automatically
"DumpLogListHashStr": None, # Will be filled automatically
})
if lL: lL.warning(f"Backward compatibility (v1.1.20 to v1.2.0): Create new attribute 'Client > DumpLog... with default parameters'") # Log about compatibility

@ -0,0 +1,14 @@
from logging import StreamHandler
class HandlerDumpLog(StreamHandler):
def __init__(self, inDict, inKeyStr, inHashKeyStr, inRowCountInt):
StreamHandler.__init__(self)
self.Dict = inDict
self.KeyStr = inKeyStr
self.HashKeyStr = inHashKeyStr
self.RowCountInt = inRowCountInt
self.Dict[self.HashKeyStr]="0"
def emit(self, inRecord):
inMessageStr = self.format(inRecord)
self.Dict[self.KeyStr].append(inMessageStr)
self.Dict[self.HashKeyStr]=str(int(self.Dict[self.HashKeyStr])+1)

@ -540,8 +540,18 @@ def GSettingsAutocleaner(inGSettings):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
from .. import __version__ # Get version from the package from .. import __version__ # Get version from the package
import logging
# Main def for orchestrator # Main def for orchestrator
def Orchestrator(inGSettings): def Orchestrator(inGSettings):
# TEst
from . import HandlerList
mHandlerDumpLogList = HandlerList.HandlerDumpLog( inDict=inGSettings["Client"],inKeyStr="DumpLogList", inHashKeyStr="DumpLogListHashStr",inRowCountInt=100)
mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
mHandlerDumpLogList.setFormatter(mRobotLoggerFormatter)
lL = inGSettings["Logger"]
lL.addHandler(mHandlerDumpLogList)
#mGlobalDict = Settings.Settings(sys.argv[1]) #mGlobalDict = Settings.Settings(sys.argv[1])
gSettingsDict = inGSettings # Alias for old name in alg gSettingsDict = inGSettings # Alias for old name in alg
inGSettings["VersionStr"] = __version__ inGSettings["VersionStr"] = __version__

@ -95,7 +95,7 @@ def pyOpenRPA_ServerData(inRequest,inGSettings):
lServerDataDictJSONStr = json.dumps(lServerDataDict) lServerDataDictJSONStr = json.dumps(lServerDataDict)
# Generate hash # Generate hash
lServerDataHashStr = str(hash(lServerDataDictJSONStr)) lServerDataHashStr = str(hash(lServerDataDictJSONStr))
if lValueStr!=lServerDataHashStr: # Case if Hash is not equal if lValueStr!=lServerDataHashStr and lServerDataHashStr!= "" and lServerDataHashStr!= None: # Case if Hash is not equal
lFlagDoGenerateBool = False lFlagDoGenerateBool = False
else: # Case Hashes are equal else: # Case Hashes are equal
time.sleep(inGSettings["Client"]["Session"]["ControlPanelRefreshIntervalSecFloat"]) time.sleep(inGSettings["Client"]["Session"]["ControlPanelRefreshIntervalSecFloat"])
@ -108,7 +108,36 @@ def pyOpenRPA_ServerData(inRequest,inGSettings):
inResponseDict["Body"] = bytes(message, "utf8") inResponseDict["Body"] = bytes(message, "utf8")
return lResult return lResult
#v1.2.0 Send data container to the client from the server
# /pyOpenRPA/ServerLog return {"HashStr" , "ServerLogList": ["row 1", "row 2"]}
# Client: mGlobal.pyOpenRPA.ServerLogListHashStr
# Client: mGlobal.pyOpenRPA.ServerLogList
def pyOpenRPA_ServerLog(inRequest,inGSDict):
# Extract the hash value from request
lValueStr = None
if inRequest.headers.get('Content-Length') is not None:
lInputByteArrayLength = int(inRequest.headers.get('Content-Length'))
lInputByteArray = inRequest.rfile.read(lInputByteArrayLength)
# Превращение массива байт в объект
lValueStr = (lInputByteArray.decode('utf8'))
# Generate ServerDataDict
lFlagDoGenerateBool = True
while lFlagDoGenerateBool:
lServerLogList = inGSDict["Client"]["DumpLogList"]
# Get hash
lServerLogListHashStr = inGSDict["Client"]["DumpLogListHashStr"]
if lValueStr!=lServerLogListHashStr and lServerLogListHashStr!= "" and lServerLogListHashStr!= None: # Case if Hash is not equal Fix because None can be obtained without JSON decode
lFlagDoGenerateBool = False
else: # Case Hashes are equal
time.sleep(inGSDict["Client"]["DumpLogListRefreshIntervalSecFloat"])
# Return the result if Hash is changed
lResult = {"HashStr": lServerLogListHashStr, "ServerLogList": lServerLogList}
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
def pyOpenRPA_Screenshot(inRequest,inGlobalDict): def pyOpenRPA_Screenshot(inRequest,inGlobalDict):
@ -159,6 +188,7 @@ def SettingsUpdate(inGlobalConfiguration):
{"Method": "POST", "URL": "/Orchestrator/UserRoleHierarchyGet", "MatchType": "Equal","ResponseDefRequestGlobal": BackwardCompatibility.v1_2_0_UserRoleHierarchyGet, "ResponseContentType": "application/json"}, {"Method": "POST", "URL": "/Orchestrator/UserRoleHierarchyGet", "MatchType": "Equal","ResponseDefRequestGlobal": BackwardCompatibility.v1_2_0_UserRoleHierarchyGet, "ResponseContentType": "application/json"},
# New way of the v.1.2.0 functionallity (all defs by the URL from /pyOpenRPA/...) # New way of the v.1.2.0 functionallity (all defs by the URL from /pyOpenRPA/...)
{"Method": "POST", "URL": "/pyOpenRPA/ServerData", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerData, "ResponseContentType": "application/json"}, {"Method": "POST", "URL": "/pyOpenRPA/ServerData", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerData, "ResponseContentType": "application/json"},
{"Method": "POST", "URL": "/pyOpenRPA/ServerLog", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerLog, "ResponseContentType": "application/json"},
{"Method": "GET", "URL": "/pyOpenRPA/Screenshot", "MatchType": "BeginWith", "ResponseDefRequestGlobal": pyOpenRPA_Screenshot, "ResponseContentType": "image/png"}, {"Method": "GET", "URL": "/pyOpenRPA/Screenshot", "MatchType": "BeginWith", "ResponseDefRequestGlobal": pyOpenRPA_Screenshot, "ResponseContentType": "image/png"},
] ]
inGlobalConfiguration["Server"]["URLList"]=inGlobalConfiguration["Server"]["URLList"]+lURLList inGlobalConfiguration["Server"]["URLList"]=inGlobalConfiguration["Server"]["URLList"]+lURLList

@ -28,8 +28,14 @@ def __Create__():
# "UserADStr": None, # User, who connect. None if user is not exists # "UserADStr": None, # User, who connect. None if user is not exists
# "DomainADStr": None, # Domain of the user who connect. None if user is not exists # "DomainADStr": None, # Domain of the user who connect. None if user is not exists
# } # }
} },
} },
# # # # # # Client... # # # # # # # #
"DumpLogListRefreshIntervalSecFloat": 5.0, # Duration between updates for the Client
"DumpLogListCountInt": 100, # Set the max row for the dump
"DumpLogList": [], # Will be filled automatically
"DumpLogListHashStr": None, # Will be filled automatically
# # # # # # # # # # # # # # # # # #
}, },
"Server": { "Server": {
"WorkingDirectoryPathStr": None, # Will be filled automatically "WorkingDirectoryPathStr": None, # Will be filled automatically
@ -287,6 +293,7 @@ def __Create__():
# inModeStr: # inModeStr:
# "BASIC" - create standart configuration # "BASIC" - create standart configuration
def Create(inModeStr="BASIC"): def Create(inModeStr="BASIC"):
if inModeStr=="BASIC": if inModeStr=="BASIC":
lResult = __Create__() # Create settings lResult = __Create__() # Create settings

@ -350,7 +350,6 @@ $(document).ready(function() {
} }
/// v1.2.0 pyOpenRPA ServerData /// v1.2.0 pyOpenRPA ServerData
mGlobal.pyOpenRPA.ServerDataDict = null mGlobal.pyOpenRPA.ServerDataDict = null
mGlobal.pyOpenRPA.ServerDataHashStr = "" mGlobal.pyOpenRPA.ServerDataHashStr = ""
mGlobal.pyOpenRPA.ServerDataRefreshDef_TechnicalRender = function() mGlobal.pyOpenRPA.ServerDataRefreshDef_TechnicalRender = function()
@ -401,8 +400,56 @@ $(document).ready(function() {
mGlobal.pyOpenRPA.ServerDataRefreshDef() // recursive mGlobal.pyOpenRPA.ServerDataRefreshDef() // recursive
} }
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
/// v1.2.0 pyOpenRPA ServerLogs
mGlobal.pyOpenRPA.ServerLogList = null
mGlobal.pyOpenRPA.ServerLogListHashStr = ""
mGlobal.pyOpenRPA.ServerLogListScrollBottomDef = function() {
var lTA = $("textarea.mGlobal-pyOpenRPA-ServerLogList")[0];
lTA.scrollTop = lTA.scrollHeight;
}
mGlobal.pyOpenRPA.ServerLogListRefreshDef_TechnicalRender = function()
{
lResponseJSON = mGlobal.pyOpenRPA.ServerLogList
if (lResponseJSON!= null) {
lText = lResponseJSON.join("\n") /// Code for the processing the text
$("textarea.mGlobal-pyOpenRPA-ServerLogList")[0].value= lText ///Прогрузить новую таблицу
mGlobal.pyOpenRPA.ServerLogListScrollBottomDef() //Scroll to the bottom
}
}
mGlobal.pyOpenRPA.ServerLogListRefreshDef=function() {
try {
$.ajax({
type: "POST",
headers: {},
url: 'pyOpenRPA/ServerLog',
data: mGlobal.pyOpenRPA.ServerLogListHashStr,
success: function(lData,l2,l3) {
try {
var lResponseJSON=JSON.parse(lData)
mGlobal.pyOpenRPA.ServerLogList = lResponseJSON["ServerLogList"]
mGlobal.pyOpenRPA.ServerLogListHashStr = lResponseJSON["HashStr"]
mGlobal.pyOpenRPA.ServerLogListRefreshDef_TechnicalRender()
}
catch(error) {
}
mGlobal.pyOpenRPA.ServerLogListRefreshDef() // recursive
},
dataType: "text",
error: function(jqXHR, textStatus, errorThrown ) {
sleep(3000)
mGlobal.pyOpenRPA.ServerLogListRefreshDef() // recursive
}
});
}
catch(error) {
sleep(3000)
mGlobal.pyOpenRPA.ServerLogListRefreshDef() // recursive
}
}
/////////////////////////////////////////////////////////////
mGlobal.Monitor.mDatasetLast = null mGlobal.Monitor.mDatasetLast = null
mGlobal.fControlPanelRefresh=function() { mGlobal.fControlPanelRefresh=function() {
@ -786,5 +833,6 @@ $(document).ready(function() {
/// v1.2.0 pyOpenRPA Init defs /// v1.2.0 pyOpenRPA Init defs
mGlobal.pyOpenRPA.ServerDataRefreshDef() // Init the refresh data def from server side mGlobal.pyOpenRPA.ServerDataRefreshDef() // Init the refresh data def from server side
mGlobal.pyOpenRPA.ServerLogListRefreshDef() // Init the refresh data def from the log window
}); });

@ -279,7 +279,7 @@
<i class="clipboard list icon"></i> <i class="clipboard list icon"></i>
Logs Logs
</h4> </h4>
<textarea readonly="readonly" style="width:100%; resize: none; font-family:inherit; font-weight: bold;" id="textarea_id" rows="20"> <textarea class="mGlobal-pyOpenRPA-ServerLogList " readonly="readonly" style="width:100%; resize: none; font-family:monospace; font-weight: bold;" id="textarea_id" rows="20">
var textarea = document.getElementById('textarea_id'); var textarea = document.getElementById('textarea_id');
textarea.scrollTop = textarea.scrollHeight; textarea.scrollTop = textarea.scrollHeight;
127.0.0.1 - - [30/Nov/2020 21:04:44] "GET /Index.js HTTP/1.1" 200 - 127.0.0.1 - - [30/Nov/2020 21:04:44] "GET /Index.js HTTP/1.1" 200 -

@ -37,6 +37,8 @@
- Create new support - CP def can return {"CPKeyStr":{"HTMLStr":"", DataDict:{}}} - Create new support - CP def can return {"CPKeyStr":{"HTMLStr":"", DataDict:{}}}
- Create CP 2 HTML generator for the backward compatibility - Create CP 2 HTML generator for the backward compatibility
- Orchestrator WEB GUI update - Administrator mode - add log view - in progress - Orchestrator WEB GUI update - Administrator mode - add log view - in progress
- - Add Server def /pyOpenRPA/ServerLogs
- - Create logger handler for the Client DumpLog
[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