# Add Processot ActivityListVerification to check structure

dev-linux
Ivan Maslov 4 years ago
parent 41b940c600
commit 67e06960e3

@ -69,4 +69,32 @@ def ActivityListExecute(inGSettings, inActivityList):
lResultList.append(e) # return the generated exception lResultList.append(e) # return the generated exception
except Exception as e: except Exception as e:
if lL: lL.exception(f"pyOpenRPA Processor.ActivityListExecute: Exception when initialisation - All activity list will be ignored.") # Logging if lL: lL.exception(f"pyOpenRPA Processor.ActivityListExecute: Exception when initialisation - All activity list will be ignored.") # Logging
return lResultList # return the result list 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.")

@ -1,5 +1,6 @@
import json import json
from .. import __Orchestrator__ 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 <script> # 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>
# USAGE: JSEscapeForHTMLInline(inJSStr="lTest=\"Hello World\"; alert(\"lTest\")") # USAGE: JSEscapeForHTMLInline(inJSStr="lTest=\"Hello World\"; alert(\"lTest\")")
def JSEscapeForHTMLInline(inJSStr): def JSEscapeForHTMLInline(inJSStr):
@ -9,6 +10,7 @@ def JSEscapeForHTMLInline(inJSStr):
# Create JS for send activity list/ activity to the processor # Create JS for send activity list/ activity to the processor
# USAGE: Orchestrator.Web.Basic.JSProcessorActivityListAdd(inActivityList) # USAGE: Orchestrator.Web.Basic.JSProcessorActivityListAdd(inActivityList)
def JSProcessorActivityListAdd(inActivityList): def JSProcessorActivityListAdd(inActivityList):
Processor.__ActivityListVerify__(inActivityList=inActivityList) # DO VERIFICATION FOR THE inActivityList
# Check if no def function is here - if exist - replace to alias # Check if no def function is here - if exist - replace to alias
for lActivityItem in inActivityList: for lActivityItem in inActivityList:
lDef = lActivityItem["Def"] lDef = lActivityItem["Def"]
@ -20,7 +22,7 @@ def JSProcessorActivityListAdd(inActivityList):
# Create JS for execute activity list/ activity permanent # Create JS for execute activity list/ activity permanent
# USAGE: Orchestrator.Web.Basic.JSActivityListExecute(inActivityList) # USAGE: Orchestrator.Web.Basic.JSActivityListExecute(inActivityList)
def JSActivityListExecute(inActivityList): def JSActivityListExecute(inActivityList):
if type(inActivityList) is not list: inActivityList = [inActivityList] Processor.__ActivityListVerify__(inActivityList=inActivityList) # DO VERIFICATION FOR THE inActivityList
lJSStr = f"""mGlobal.pyOpenRPA.ActivityListExecute({json.dumps(inActivityList)});""" lJSStr = f"""mGlobal.pyOpenRPA.ActivityListExecute({json.dumps(inActivityList)});"""
return lJSStr return lJSStr

@ -735,6 +735,7 @@ def SchedulerActivityTimeAddWeekly(inGSettings, inTimeHHMMStr="23:55:", inWeekda
""" """
if inWeekdayList is None: inWeekdayList=[] if inWeekdayList is None: inWeekdayList=[]
if inActivityList is None: inActivityList=[] if inActivityList is None: inActivityList=[]
Processor.__ActivityListVerify__(inActivityList=inActivityList) # DO VERIFICATION FOR THE inActivityList
lActivityTimeItemDict = { lActivityTimeItemDict = {
"TimeHH:MMStr": inTimeHHMMStr, # Time [HH:MM] to trigger activity "TimeHH:MMStr": inTimeHHMMStr, # Time [HH:MM] to trigger activity
"WeekdayList": inWeekdayList, # List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7] "WeekdayList": inWeekdayList, # List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
@ -1346,7 +1347,7 @@ def Orchestrator(inGSettings):
lActivityDateTime>=lDaemonLastDateTime and lActivityDateTime>=lDaemonLastDateTime and
lCurrentDateTime>=lActivityDateTime): lCurrentDateTime>=lActivityDateTime):
# Log info about activity # Log info about activity
if lL: lL.info(f"Scheduler:: Activity list is started in new thread. Scheduler item: {lItem}") #Logging if lL: lL.info(f"Scheduler:: Activity list is started in new thread. Parameters are not available to see.") #Logging
# Do the activity # Do the activity
lThread = threading.Thread(target=Processor.ActivityListExecute, kwargs={"inGSettings": inGSettings, "inActivityList":lItem["ActivityList"]}) lThread = threading.Thread(target=Processor.ActivityListExecute, kwargs={"inGSettings": inGSettings, "inActivityList":lItem["ActivityList"]})
lThread.start() lThread.start()

Loading…
Cancel
Save