@ -53,8 +53,10 @@ def HiddenJSInitGenerate(inRequest, inGSettings):
# Generate CP HTML + JSON
# Generate CP HTML + JSON
# Return {"Key":{"",""}}
# Return {"Key":{"",""}}
def HiddenCPDictGenerate ( inRequest , inGSettings ) :
def HiddenCPDictGenerate ( inAuthTokenStr ) :
dUAC = inRequest . UACClientCheck # Alias.
inGSettings = __Orchestrator__ . GSettingsGet ( )
dUAC = lambda inKeyList : __Orchestrator__ . WebUserUACCheck ( inAuthTokenStr = inAuthTokenStr , inKeyList = inKeyList )
#dUAC = d_uac #inRequest.UACClientCheck # Alias.
lUACCPTemplateKeyList = [ " pyOpenRPADict " , " CPKeyDict " ]
lUACCPTemplateKeyList = [ " pyOpenRPADict " , " CPKeyDict " ]
lL = inGSettings [ " Logger " ] # Alias for logger
lL = inGSettings [ " Logger " ] # Alias for logger
# Create result JSON
# Create result JSON
@ -62,15 +64,15 @@ def HiddenCPDictGenerate(inRequest, inGSettings):
lRenderFunctionsRobotDict = inGSettings [ " ServerDict " ] [ " ControlPanelDict " ]
lRenderFunctionsRobotDict = inGSettings [ " ServerDict " ] [ " ControlPanelDict " ]
for lItemKeyStr in lRenderFunctionsRobotDict :
for lItemKeyStr in lRenderFunctionsRobotDict :
lItemDict = lRenderFunctionsRobotDict [ lItemKeyStr ]
lItemDict = lRenderFunctionsRobotDict [ lItemKeyStr ]
lUACBool = dUAC ( in Role KeyList= lUACCPTemplateKeyList + [ lItemKeyStr ] ) # Check if render function is applicable User Access Rights (UAC)
lUACBool = dUAC ( in KeyList= lUACCPTemplateKeyList + [ lItemKeyStr ] ) # Check if render function is applicable User Access Rights (UAC)
if lItemKeyStr == " VersionCheck " : lUACBool = True # For backward compatibility for the old fron version which not reload page when new orch version is comming
if lItemKeyStr == " VersionCheck " : lUACBool = True # For backward compatibility for the old fron version which not reload page when new orch version is comming
if lUACBool : # Run function if UAC is TRUE
if lUACBool : # Run function if UAC is TRUE
lCPItemDict = { " HTMLStr " : None , " JSONDict " : None }
lCPItemDict = { " HTMLStr " : None , " JSONDict " : None }
try :
try :
# HTML Render
# HTML Render
lCPItemDict [ " HTMLStr " ] = lItemDict . OnRefreshHTMLStr ( in Request= inRequest )
lCPItemDict [ " HTMLStr " ] = lItemDict . OnRefreshHTMLStr ( in AuthTokenStr= inAuthTokenStr )
# JSONGeneratorDef
# JSONGeneratorDef
lCPItemDict [ " JSONDict " ] = lItemDict . OnRefreshJSONDict ( in Request= inRequest )
lCPItemDict [ " JSONDict " ] = lItemDict . OnRefreshJSONDict ( in AuthTokenStr= inAuthTokenStr )
except Exception as e :
except Exception as e :
lL . exception ( f " EXCEPTION WHEN HTML/ JSON RENDER " )
lL . exception ( f " EXCEPTION WHEN HTML/ JSON RENDER " )
# Insert CPItemDict in result CPDict
# Insert CPItemDict in result CPDict
@ -78,14 +80,15 @@ def HiddenCPDictGenerate(inRequest, inGSettings):
return lCPDict
return lCPDict
# Return {"Key":{"",""}}
# Return {"Key":{"",""}}
def HiddenRDPDictGenerate ( inRequest , inGSettings ) :
def HiddenRDPDictGenerate ( inAuthTokenStr ) :
dUAC = inRequest . UACClientCheck # Alias.
inGSettings = __Orchestrator__ . GSettingsGet ( )
dUAC = lambda inKeyList : __Orchestrator__ . WebUserUACCheck ( inAuthTokenStr = inAuthTokenStr , inKeyList = inKeyList )
lUACRDPTemplateKeyList = [ " pyOpenRPADict " , " RDPKeyDict " ]
lUACRDPTemplateKeyList = [ " pyOpenRPADict " , " RDPKeyDict " ]
lRDPDict = { " HandlebarsList " : [ ] }
lRDPDict = { " HandlebarsList " : [ ] }
# Iterate throught the RDP list
# Iterate throught the RDP list
for lRDPSessionKeyStrItem in inGSettings [ " RobotRDPActive " ] [ " RDPList " ] :
for lRDPSessionKeyStrItem in inGSettings [ " RobotRDPActive " ] [ " RDPList " ] :
# Check UAC
# Check UAC
if dUAC ( in Role KeyList= lUACRDPTemplateKeyList + [ lRDPSessionKeyStrItem ] ) :
if dUAC ( in KeyList= lUACRDPTemplateKeyList + [ lRDPSessionKeyStrItem ] ) :
lRDPConfiguration = inGSettings [ " RobotRDPActive " ] [ " RDPList " ] [
lRDPConfiguration = inGSettings [ " RobotRDPActive " ] [ " RDPList " ] [
lRDPSessionKeyStrItem ] # Get the configuration dict
lRDPSessionKeyStrItem ] # Get the configuration dict
lDataItemDict = { " SessionKeyStr " : " " , " SessionHexStr " : " " , " IsFullScreenBool " : False ,
lDataItemDict = { " SessionKeyStr " : " " , " SessionHexStr " : " " , " IsFullScreenBool " : False ,
@ -102,15 +105,16 @@ def HiddenRDPDictGenerate(inRequest, inGSettings):
return lRDPDict
return lRDPDict
# Return {"HostNameUpperStr;UserUpperStr":{"IsListenBool":True}, "HandlebarsList":[{"HostnameUpperStr":"","UserUpperStr":"","IsListenBool":True}]}
# Return {"HostNameUpperStr;UserUpperStr":{"IsListenBool":True}, "HandlebarsList":[{"HostnameUpperStr":"","UserUpperStr":"","IsListenBool":True}]}
def HiddenAgentDictGenerate ( inRequest , inGSettings ) :
def HiddenAgentDictGenerate ( inAuthTokenStr ) :
dUAC = inRequest . UACClientCheck # Alias.
inGSettings = __Orchestrator__ . GSettingsGet ( )
dUAC = lambda inKeyList : __Orchestrator__ . WebUserUACCheck ( inAuthTokenStr = inAuthTokenStr , inKeyList = inKeyList )
lUACAgentTemplateKeyList = [ " pyOpenRPADict " , " AgentKeyDict " ]
lUACAgentTemplateKeyList = [ " pyOpenRPADict " , " AgentKeyDict " ]
lAgentDict = { " HandlebarsList " : [ ] }
lAgentDict = { " HandlebarsList " : [ ] }
# Iterate throught the RDP list
# Iterate throught the RDP list
for lAgentItemKeyStrItem in inGSettings [ " AgentDict " ] :
for lAgentItemKeyStrItem in inGSettings [ " AgentDict " ] :
# Check UAC
# Check UAC
lKeyStr = f " { lAgentItemKeyStrItem [ 0 ] } ; { lAgentItemKeyStrItem [ 1 ] } " # turple ("HostNameUpperStr","UserUpperStr") > Str "HostNameUpperStr;UserUpperStr"
lKeyStr = f " { lAgentItemKeyStrItem [ 0 ] } ; { lAgentItemKeyStrItem [ 1 ] } " # turple ("HostNameUpperStr","UserUpperStr") > Str "HostNameUpperStr;UserUpperStr"
if dUAC ( in Role KeyList= lUACAgentTemplateKeyList + [ lKeyStr ] ) :
if dUAC ( in KeyList= lUACAgentTemplateKeyList + [ lKeyStr ] ) :
lDataItemDict = inGSettings [ " AgentDict " ] [ lAgentItemKeyStrItem ]
lDataItemDict = inGSettings [ " AgentDict " ] [ lAgentItemKeyStrItem ]
lDataItemAgentDict = copy . deepcopy ( lDataItemDict )
lDataItemAgentDict = copy . deepcopy ( lDataItemDict )
lDataItemAgentDict [ " ActivityList " ] = [ ]
lDataItemAgentDict [ " ActivityList " ] = [ ]
@ -128,33 +132,42 @@ def HiddenAgentDictGenerate(inRequest, inGSettings):
# Client: mGlobal.pyOpenRPA.ServerDataHashStr
# Client: mGlobal.pyOpenRPA.ServerDataHashStr
# Client: mGlobal.pyOpenRPA.ServerDataDict
# Client: mGlobal.pyOpenRPA.ServerDataDict
def pyOpenRPA_ServerData ( inRequest , inGSettings ) :
import asyncio
from fastapi import Request
@app.post ( " /orpa/client/server-data " , response_class = JSONResponse )
#{"Method": "POST", "URL": "/orpa/client/server-data", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerData, "ResponseContentType": "application/json"},
async def pyOpenRPA_ServerData ( inRequest : Request ) :
inGSettings = __Orchestrator__ . GSettingsGet ( )
print ( f " START pyOpenRPA_ServerData " )
# Extract the hash value from request
# Extract the hash value from request
lValueStr = inRequest . body
lValueStr = await inRequest . body ( )
lValueStr = lValueStr . decode ( " utf8 " )
# Generate ServerDataDict
# Generate ServerDataDict
lFlagDoGenerateBool = True
lFlagDoGenerateBool = True
while lFlagDoGenerateBool :
while lFlagDoGenerateBool :
lServerDataDict = {
lServerDataDict = {
" CPDict " : HiddenCPDictGenerate ( inRequest = inRequest , inGSettings = inGSettings ) ,
" CPDict " : None , #HiddenCPDictGenerate(inRequest=inRequest, inGSettings=inGSettings) ,
" RDPDict " : HiddenRDPDictGenerate ( inRequest = inRequest , inGSettings = inGSettings ) ,
" RDPDict " : None , #HiddenRDPDictGenerate(inRequest=inRequest, inGSettings=inGSettings) ,
" AgentDict " : HiddenAgentDictGenerate ( inRequest = inRequest , inGSettings = inGSettings ) ,
" AgentDict " : None , #HiddenAgentDictGenerate(inRequest=inRequest, inGSettings=inGSettings) ,
" UserDict " : { " UACClientDict " : inRequest . OpenRPA [ " DefUserRoleHierarchyGet " ] ( ) , " CWDPathStr " : os . getcwd ( ) , " VersionStr " : inGSettings [ " VersionStr " ] } ,
" UserDict " : { " UACClientDict " : { } , " CWDPathStr " : os . getcwd ( ) , " VersionStr " : inGSettings [ " VersionStr " ] } ,
}
} # inRequest.OpenRPA["DefUserRoleHierarchyGet"]()
# Create JSON
# Create JSON
lServerDataDictJSONStr = json . dumps ( lServerDataDict )
lServerDataDictJSONStr = json . dumps ( lServerDataDict )
# Generate hash
# Generate hash
lServerDataHashStr = str ( hash ( lServerDataDictJSONStr ) )
lServerDataHashStr = str ( hash ( lServerDataDictJSONStr ) )
if lValueStr != lServerDataHashStr and lServerDataHashStr != " " and lServerDataHashStr != None : # Case if Hash is not equal
if lValueStr != lServerDataHashStr and lServerDataHashStr != " " and lServerDataHashStr != None : # Case if Hash is not equal
print ( f " lValueStr: { lValueStr } , lServerDataHashStr: { lServerDataHashStr } " )
lFlagDoGenerateBool = False
lFlagDoGenerateBool = False
else : # Case Hashes are equal
else : # Case Hashes are equal
time . sleep ( inGSettings [ " Client " ] [ " Session " ] [ " ControlPanelRefreshIntervalSecFloat " ] )
await asyncio . 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
#inResponseDict = inRequest. OpenRPAResponseDict
# Send message back to client
# Send message back to client
message = json . dumps ( lResult )
#message = json.dumps(lResult )
# Write content as utf-8 data
# Write content as utf-8 data
inResponseDict [ " Body " ] = bytes ( message , " utf8 " )
#inResponseDict["Body"] = bytes(message, "utf8")
print ( f " STOP pyOpenRPA_ServerData " )
return lResult
return lResult
# GET
# GET
@ -171,7 +184,7 @@ def pyOpenRPA_ServerJSInit(inRequest,inGSettings):
# /pyOpenRPA/ServerLog return {"HashStr" , "ServerLogList": ["row 1", "row 2"]}
# /pyOpenRPA/ServerLog return {"HashStr" , "ServerLogList": ["row 1", "row 2"]}
# Client: mGlobal.pyOpenRPA.ServerLogListHashStr
# Client: mGlobal.pyOpenRPA.ServerLogListHashStr
# Client: mGlobal.pyOpenRPA.ServerLogList
# Client: mGlobal.pyOpenRPA.ServerLogList
def pyOpenRPA_ServerLog ( inRequest , inGSDict ) :
async def pyOpenRPA_ServerLog ( inRequest , inGSDict ) :
# Extract the hash value from request
# Extract the hash value from request
lValueStr = inRequest . body
lValueStr = inRequest . body
# Generate ServerDataDict
# Generate ServerDataDict
@ -183,7 +196,7 @@ def pyOpenRPA_ServerLog(inRequest,inGSDict):
if lValueStr != lServerLogListHashStr and lServerLogListHashStr != " " and lServerLogListHashStr != None : # Case if Hash is not equal Fix because None can be obtained without JSON decode
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
lFlagDoGenerateBool = False
else : # Case Hashes are equal
else : # Case Hashes are equal
time . sleep ( inGSDict [ " Client " ] [ " DumpLogListRefreshIntervalSecFloat " ] )
asyncio . sleep ( inGSDict [ " Client " ] [ " DumpLogListRefreshIntervalSecFloat " ] )
# Return the result if Hash is changed
# Return the result if Hash is changed
lResult = { " HashStr " : lServerLogListHashStr , " ServerLogList " : lServerLogList }
lResult = { " HashStr " : lServerLogListHashStr , " ServerLogList " : lServerLogList }
inResponseDict = inRequest . OpenRPAResponseDict
inResponseDict = inRequest . OpenRPAResponseDict
@ -512,9 +525,9 @@ def SettingsUpdate():
#{"Method": "GET", "URL": "/pyOpenRPA_logo.png", "MatchType": "Equal", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\pyOpenRPA_logo.png"), "ResponseContentType": "image/png", "UACBool":False, "UseCacheBool": True},
#{"Method": "GET", "URL": "/pyOpenRPA_logo.png", "MatchType": "Equal", "ResponseFilePath": os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\pyOpenRPA_logo.png"), "ResponseContentType": "image/png", "UACBool":False, "UseCacheBool": True},
{ " Method " : " POST " , " URL " : " /orpa/client/user-role-hierarchy-get " , " MatchType " : " Equal " , " ResponseDefRequestGlobal " : BackwardCompatibility . v1_2_0_UserRoleHierarchyGet , " ResponseContentType " : " application/json " } ,
{ " Method " : " POST " , " URL " : " /orpa/client/user-role-hierarchy-get " , " 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 " : " /orpa/client/server-data " , " MatchType " : " Equal " , " ResponseDefRequestGlobal " : pyOpenRPA_ServerData , " ResponseContentType " : " application/json " } ,
#{"Method": "POST", "URL": "/orpa/client/server-data", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerData, "ResponseContentType": "application/json"} ,
{ " Method " : " GET " , " URL " : " /orpa/client/server-js-init " , " MatchType " : " Equal " , " ResponseDefRequestGlobal " : pyOpenRPA_ServerJSInit , " ResponseContentType " : " application/javascript " } ,
{ " Method " : " GET " , " URL " : " /orpa/client/server-js-init " , " MatchType " : " Equal " , " ResponseDefRequestGlobal " : pyOpenRPA_ServerJSInit , " ResponseContentType " : " application/javascript " } ,
{ " Method " : " POST " , " URL " : " /orpa/client/server-log " , " MatchType " : " Equal " , " ResponseDefRequestGlobal " : pyOpenRPA_ServerLog , " ResponseContentType " : " application/json " } ,
#{"Method": "POST", "URL": "/orpa/client/server-log", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerLog, "ResponseContentType": "application/json"} ,
#{"Method": "GET", "URL": "/orpa/client/screenshot-get", "MatchType": "Equal", "ResponseDefRequestGlobal": pyOpenRPA_Screenshot, "ResponseContentType": "image/png"},
#{"Method": "GET", "URL": "/orpa/client/screenshot-get", "MatchType": "Equal", "ResponseDefRequestGlobal": pyOpenRPA_Screenshot, "ResponseContentType": "image/png"},
# API
# API
#{"Method": "POST", "URL": "/orpa/api/processor-queue-add", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_Processor, "ResponseContentType": "application/json"},
#{"Method": "POST", "URL": "/orpa/api/processor-queue-add", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_Processor, "ResponseContentType": "application/json"},