From 67e06960e3c3284340fbec5358c4a68dd694eaa2 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Mon, 15 Feb 2021 10:23:29 +0300 Subject: [PATCH] # Add Processot ActivityListVerification to check structure --- Sources/pyOpenRPA/Orchestrator/Processor.py | 30 ++++++++++++++++++- Sources/pyOpenRPA/Orchestrator/Web/Basic.py | 4 ++- .../Orchestrator/__Orchestrator__.py | 3 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/Processor.py b/Sources/pyOpenRPA/Orchestrator/Processor.py index 9f99611c..19145583 100644 --- a/Sources/pyOpenRPA/Orchestrator/Processor.py +++ b/Sources/pyOpenRPA/Orchestrator/Processor.py @@ -69,4 +69,32 @@ def ActivityListExecute(inGSettings, inActivityList): lResultList.append(e) # return the generated exception except Exception as e: if lL: lL.exception(f"pyOpenRPA Processor.ActivityListExecute: Exception when initialisation - All activity list will be ignored.") # Logging - return lResultList # return the result list \ No newline at end of file + return lResultList # return the result list + +def __ActivityListVerify__(inActivityList): + """ + Verify ActivityList variable - raise exception if input list is not list of dict with structure: + # "Def":"DefAliasTest", # def link or def alias (look gSettings["Processor"]["AliasDefDict"]) + # "ArgList":[1,2,3], # Args list + # "ArgDict":{"ttt":1,"222":2,"dsd":3}, # Args dictionary + # "ArgGSettings": None # Name of GSettings attribute: str (ArgDict) or index (for ArgList) + # "ArgLogger": None # Name of GSettings attribute: str (ArgDict) or index (for ArgList) + + :param inActivityList: + :return: + """ + # CASE LIST + if type(inActivityList) is list: + for lItem in inActivityList: + # CASE LIST item is LIST + if type(lItem) is list: + raise Exception(f"pyOpenRPA Processor.__ActivityListVerify__: inActivityList has wrong structure! Details: Your ActivityList item is list too. List of the list :(") + # CASE Item is not dict + if type(lItem) is not dict: + raise Exception(f"pyOpenRPA Processor.__ActivityListVerify__: inActivityList has wrong structure! Details: Your ActivityList item is is not dict") + # CASE HAS NO "Def" + if "Def" not in lItem: + raise Exception(f"pyOpenRPA Processor.__ActivityListVerify__: inActivityList has wrong structure! Details: Activity item has no attribute 'Def'") + #CASE NOT LIST + else: + raise Exception(f"pyOpenRPA Processor.__ActivityListVerify__: inActivityList has wrong structure! Details: Your ActivityList is not a list.") \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Basic.py b/Sources/pyOpenRPA/Orchestrator/Web/Basic.py index 366e56b4..cc39e082 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Basic.py +++ b/Sources/pyOpenRPA/Orchestrator/Web/Basic.py @@ -1,5 +1,6 @@ import json from .. import __Orchestrator__ +from .. import Processor # 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