diff --git a/Sources/Sandbox/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/Sources/Sandbox/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 00000000..7fec5150 --- /dev/null +++ b/Sources/Sandbox/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Sources/Sandbox/Untitled.ipynb b/Sources/Sandbox/Untitled.ipynb new file mode 100644 index 00000000..446568b3 --- /dev/null +++ b/Sources/Sandbox/Untitled.ipynb @@ -0,0 +1,64 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "def t(*in_arg_list):\n", + " for l_item in in_arg_list:\n", + " print(l_item)\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "2\n", + "1\n" + ] + } + ], + "source": [ + "t(3,2,1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py b/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py index 7abd8a37..b8f7052b 100644 --- a/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py +++ b/Sources/pyOpenRPA/Orchestrator/BackwardCompatibility.py @@ -526,3 +526,10 @@ def Update(inGSettings): inGSettings["ProcessorDict"]["ActivityItemNowDict"]=None if lL: lL.warning( f"Backward compatibility (v1.2.4 to v1.2.7): Create new key: ProcessorDict > ActivityItemNowDict") # Log about compatibility + + # # "UACBool": True # True - check user access before do this URL item + for lURLItemDict in inGSettings["ServerDict"]["URLList"]: + if "UACBool" not in lURLItemDict: + lURLItemDict["UACBool"]=None + if lL: lL.warning( + f"Backward compatibility (v1.2.4 to v1.2.7): ServerDict > URLList > item: add UACBool = None") # Log about compatibility diff --git a/Sources/pyOpenRPA/Orchestrator/Server.py b/Sources/pyOpenRPA/Orchestrator/Server.py index d39ab81a..ceb0afb7 100644 --- a/Sources/pyOpenRPA/Orchestrator/Server.py +++ b/Sources/pyOpenRPA/Orchestrator/Server.py @@ -261,7 +261,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): #Tech def #return {"headers":[],"body":"","statuscode":111} - def URLItemCheckDo(self, inURLItem, inMethod): + def URLItemCheckDo(self, inURLItem, inMethod, inOnlyFlagUACBool = False): ############################### #Tech sub def - do item ################################ @@ -305,6 +305,9 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): # Закрыть файловый объект lFileObject.close() ############################################## + # UAC Check + if inOnlyFlagUACBool == True and inURLItem.get("UACBool",None) in [None, False]: + return False if inURLItem["Method"].upper() == inMethod.upper(): # check Match type variant: BeginWith if inURLItem["MatchType"].upper() == "BEGINWITH": @@ -378,6 +381,16 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): # Prepare result dict lResponseDict = {"Headers": {}, "SetCookies": {}, "Body": b"", "StatusCode": None} self.OpenRPAResponseDict = lResponseDict + ############################ + #First - all with Flag UACBool + ############################ + for lURLItem in gSettingsDict["ServerDict"]["URLList"]: + #Check if all condition are applied + lFlagURLIsApplied=False + lFlagURLIsApplied=self.URLItemCheckDo(inURLItem=lURLItem, inMethod="GET", inOnlyFlagUACBool=True) + if lFlagURLIsApplied: + self.ResponseDictSend() + return ##################################### #Do authentication #Check if authentication is turned on @@ -454,6 +467,16 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): #pdb.set_trace() lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": b"", "StatusCode": None} self.OpenRPAResponseDict = lResponseDict + ############################ + #First - all with Flag UACBool + ############################ + for lURLItem in gSettingsDict["ServerDict"]["URLList"]: + #Check if all condition are applied + lFlagURLIsApplied=False + lFlagURLIsApplied=self.URLItemCheckDo(inURLItem=lURLItem, inMethod="POST", inOnlyFlagUACBool=True) + if lFlagURLIsApplied: + self.ResponseDictSend() + return ##################################### #Do authentication #Check if authentication is turned on diff --git a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py index 6515d697..bcc42316 100644 --- a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py +++ b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py @@ -109,7 +109,8 @@ def __Create__(): # "ResponseFilePath": "", #Absolute or relative path # "ResponseFolderPath": "", #Absolute or relative path # "ResponseContentType": "", #HTTP Content-type - # "ResponseDefRequestGlobal": None #Function with str result + # "ResponseDefRequestGlobal": None ,#Function with str result + # "UACBool": True # True - check user access before do this URL item. None - get Server flag if ask user # } { "Method": "GET", @@ -120,6 +121,7 @@ def __Create__(): # Absolute or relative path # "ResponseContentType": "", #HTTP Content-type # "ResponseDefRequestGlobal": None #Function with str result + # "UACBool": True # True - check user access before do this URL item } ], diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index bd99f577..714aa4de 100644 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -842,7 +842,7 @@ def UACSuperTokenUpdate(inSuperTokenStr, inGSettings=None): # # # # # # # # # # # # # # # # # # # # # # # -def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentTypeStr="application/octet-stream", inGSettings = None): +def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentTypeStr="application/octet-stream", inGSettings = None, inUACBool = None): """ Connect URL to DEF "inMethodStr":"GET|POST", @@ -857,6 +857,7 @@ def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentType :param inMatchTypeStr: #"BeginWith|Contains|Equal|EqualCase", :param inDef: def arg allowed list: 2:[inRequest, inGSettings], 1: [inRequest], 0: [] :param inContentTypeStr: default: "application/octet-stream" + :param inUACBool: default: None; True - check user access before do this URL item. None - get Server flag if ask user """ inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings lURLItemDict = { @@ -867,24 +868,27 @@ def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentType #"ResponseFolderPath": "C:\Abs\Archive\scopeSrcUL\OpenRPA\Orchestrator\Settings", # Absolute or relative path "ResponseContentType": inContentTypeStr, #HTTP Content-type - "ResponseDefRequestGlobal": inDef #Function with str result + "ResponseDefRequestGlobal": inDef, #Function with str result + "UACBool": inUACBool } inGSettings["ServerDict"]["URLList"].append(lURLItemDict) -def WebURLConnectFolder(inMethodStr, inURLStr, inMatchTypeStr, inFolderPathStr, inGSettings = None): +def WebURLConnectFolder(inMethodStr, inURLStr, inMatchTypeStr, inFolderPathStr, inGSettings = None, inUACBool = None): """ Connect URL to Folder "inMethodStr":"GET|POST", "inURLStr": "/Folder/", #URL of the request "inMatchTypeStr": "", #"BeginWith|Contains|Equal|EqualCase", "inFolderPathStr": "", #Absolute or relative path + "inUACBool" :param inGSettings: Global settings dict (singleton) :param inMethodStr: :param inURLStr: :param inMatchTypeStr: :param inFolderPathStr: + :param inUACBool: default: None; True - check user access before do this URL item. None - get Server flag if ask user """ inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings # Check if last symbol is "/" - append if not exist @@ -899,11 +903,12 @@ def WebURLConnectFolder(inMethodStr, inURLStr, inMatchTypeStr, inFolderPathStr, "ResponseFolderPath": lFolderPathStr, # Absolute or relative path "ResponseContentType": "application/octet-stream", #HTTP Content-type #"ResponseDefRequestGlobal": inDef #Function with str result + "UACBool": inUACBool } inGSettings["ServerDict"]["URLList"].append(lURLItemDict) -def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inContentTypeStr="application/octet-stream", inGSettings = None): +def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inContentTypeStr="application/octet-stream", inGSettings = None, inUACBool = None): """ Connect URL to File "inMethodStr":"GET|POST", @@ -917,6 +922,7 @@ def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inCo :param inMatchTypeStr: :param inFilePathStr: :param inContentTypeStr: + :param inUACBool: default: None; True - check user access before do this URL item. None - get Server flag if ask user """ inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings lURLItemDict = { @@ -927,6 +933,7 @@ def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inCo #"ResponseFolderPath": os.path.abspath(inFilePathStr), # Absolute or relative path "ResponseContentType": inContentTypeStr, #HTTP Content-type #"ResponseDefRequestGlobal": inDef #Function with str result + "UACBool":inUACBool } inGSettings["ServerDict"]["URLList"].append(lURLItemDict)