From ecce39c2346d1d52747b079b3b04e0e86151b731 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sat, 13 Feb 2021 19:37:22 +0300 Subject: [PATCH] # Now Activity Item Support "" value for ArgGSettings and ArgLogger # Basic.JSProcessorActivityListAdd - raise exception if Def is not string # Orchestrator.ProcessorAliasDefUpdate fix if inDef is not a function - raise Exception # Scheduler major bugfix! It works now! --- Sources/GuideSphinx/make_ENG_Guide.bat | 2 +- Sources/pyOpenRPA/Orchestrator/Processor.py | 6 +++--- Sources/pyOpenRPA/Orchestrator/Web/Basic.py | 14 ++++++++++---- Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py | 7 ++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Sources/GuideSphinx/make_ENG_Guide.bat b/Sources/GuideSphinx/make_ENG_Guide.bat index 7c357bd7..5b200958 100644 --- a/Sources/GuideSphinx/make_ENG_Guide.bat +++ b/Sources/GuideSphinx/make_ENG_Guide.bat @@ -1,7 +1,7 @@ cd %~dp0 @ECHO OFF set PATH=%PATH%;%~dp0..\..\Resources\WPy64-3720\python-3.7.2.amd64\Scripts -set PYTHONPATH=%PATH%;%~dp0..\..\Resources\WPy64-3720\python-3.7.2.amd64\Scripts +set PYTHONPATH=%PYTHONPATH%;%~dp0..\..\Resources\WPy64-3720\python-3.7.2.amd64\Scripts pushd %~dp0 REM Command file for Sphinx documentation diff --git a/Sources/pyOpenRPA/Orchestrator/Processor.py b/Sources/pyOpenRPA/Orchestrator/Processor.py index 823f48c8..ceefcc7e 100644 --- a/Sources/pyOpenRPA/Orchestrator/Processor.py +++ b/Sources/pyOpenRPA/Orchestrator/Processor.py @@ -47,15 +47,15 @@ def ActivityListExecute(inGSettings, inActivityList): #gSettings lGSettingsDictKey = lActivityItem.pop("ArgGSettings",None) # # Prepare arg dict - gSettings - if type(lGSettingsDictKey) is str: # check if gSetting key is in ArgDict + if type(lGSettingsDictKey) is str and lGSettingsDictKey is not "": # check if gSetting key is in ArgDict 13.02.2021 - Fix when ArgGSettings is "" lActivityItem["ArgDict"][lGSettingsDictKey] = inGSettings # Set the gSettings in dict # # Prepare arg list elif type(lGSettingsDictKey) is int: # check if gSetting key is in ArgDict lActivityItem["ArgList"].insert(lGSettingsDictKey,inGSettings)# Set the gSettings in list by the index #Logger lLoggerDictKey = lActivityItem.pop("ArgLogger",None) - # # Prepare arg dict - gSettings - if type(lLoggerDictKey) is str: # check if gSetting key is in ArgDict + # # Prepare arg dict - Logger + if type(lLoggerDictKey) is str and lLoggerDictKey is not "": # check if gSetting key is in ArgDict 13.02.2021 - Fix when ArgLogger is "" lActivityItem["ArgDict"][lLoggerDictKey] = lL # Set the lLogger in dict # # Prepare arg list elif type(lLoggerDictKey) is int: # check if gSetting key is in ArgDict diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Basic.py b/Sources/pyOpenRPA/Orchestrator/Web/Basic.py index 68d2de99..366e56b4 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Basic.py +++ b/Sources/pyOpenRPA/Orchestrator/Web/Basic.py @@ -9,6 +9,10 @@ def JSEscapeForHTMLInline(inJSStr): # Create JS for send activity list/ activity to the processor # USAGE: Orchestrator.Web.Basic.JSProcessorActivityListAdd(inActivityList) def JSProcessorActivityListAdd(inActivityList): + # Check if no def function is here - if exist - replace to alias + for lActivityItem in inActivityList: + lDef = lActivityItem["Def"] + if callable(lDef): raise Exception(f"pyOpenRPA Exception: You can't send ActivityList with def to JS. Use Def Alias (see Orchestrator.ProcessorAliasDefUpdate)") if type(inActivityList) is not list: inActivityList = [inActivityList] lJSStr = f"""mGlobal.pyOpenRPA.ProcessorQueueAdd({json.dumps(inActivityList)});""" return lJSStr @@ -43,9 +47,10 @@ def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None): # Create HTMLLink by the def, argdict, arglist, gsettingsStr, logger Str titleStr, color, (add in processor queue) def HTMLLinkDefProcessor(inGSettings, inDef, inArgDict=None, inArgList=None, inArgGSettingsStr=None, inArgLoggerStr=None, inLinkTitleStr=None, inLinkColorStr=""): lDefAliasStr = inDef - if callable(inDef): lDefAliasStr = str(inDef) + if callable(inDef): + lDefAliasStr = str(inDef) + lDefAliasStr = __Orchestrator__.ProcessorAliasDefUpdate(inGSettings=inGSettings, inDef=inDef, inAliasStr=lDefAliasStr) if inLinkTitleStr is None: inLinkTitleStr = lDefAliasStr - lDefAliasStr=__Orchestrator__.ProcessorAliasDefUpdate(inGSettings=inGSettings, inDef=inDef, inAliasStr=lDefAliasStr) lActivityList = [__Orchestrator__.ProcessorActivityItemCreate(inDef=lDefAliasStr,inArgList=inArgList,inArgDict=inArgDict,inArgGSettingsStr=inArgGSettingsStr,inArgLoggerStr=inArgLoggerStr)] lJSStr = JSProcessorActivityListAdd(lActivityList) lHTMLStr = HTMLLinkJSOnClick(inJSOnClickStr=lJSStr,inTitleStr=inLinkTitleStr, inColorStr=inLinkColorStr) @@ -54,9 +59,10 @@ def HTMLLinkDefProcessor(inGSettings, inDef, inArgDict=None, inArgList=None, inA # Create HTMLLink by the def, argdict, arglist, gsettingsStr, logger Str titleStr, color, (execute permanently) def HTMLLinkDefExecute(inGSettings, inDef, inArgDict=None, inArgList=None, inArgGSettingsStr=None, inArgLoggerStr=None, inLinkTitleStr=None, inLinkColorStr=""): lDefAliasStr = inDef - if callable(inDef): lDefAliasStr = str(inDef) + if callable(inDef): + lDefAliasStr = str(inDef) + lDefAliasStr = __Orchestrator__.ProcessorAliasDefUpdate(inGSettings=inGSettings, inDef=inDef, inAliasStr=lDefAliasStr) if inLinkTitleStr is None: inLinkTitleStr = lDefAliasStr - lDefAliasStr=__Orchestrator__.ProcessorAliasDefUpdate(inGSettings=inGSettings, inDef=inDef, inAliasStr=lDefAliasStr) lActivityList = [__Orchestrator__.ProcessorActivityItemCreate(inDef=lDefAliasStr,inArgList=inArgList,inArgDict=inArgDict,inArgGSettingsStr=inArgGSettingsStr,inArgLoggerStr=inArgLoggerStr)] lJSStr = JSActivityListExecute(lActivityList) lHTMLStr = HTMLLinkJSOnClick(inJSOnClickStr=lJSStr,inTitleStr=inLinkTitleStr, inColorStr=inLinkColorStr) diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index 5461b052..10fd0f38 100644 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -545,7 +545,8 @@ def ProcessorAliasDefUpdate(inGSettings, inDef, inAliasStr): :param inAliasStr: :return: str Alias """ - inGSettings["ProcessorDict"]["AliasDefDict"][inAliasStr] = inDef + if callable(inDef): inGSettings["ProcessorDict"]["AliasDefDict"][inAliasStr] = inDef + else: raise Exception(f"pyOpenRPA Exception: You can't use Orchestrator.ProcessorAliasDefUpdate with arg 'inDef' string value. inDef is '{inDef}', inAliasStr is '{inAliasStr}'") return inAliasStr def ProcessorActivityItemCreate(inDef, inArgList=None, inArgDict=None, inArgGSettingsStr=None, inArgLoggerStr=None): @@ -1334,11 +1335,11 @@ def Orchestrator(inGSettings): ####################################################################### #Branch 1 - if has TimeHH:MM ####################################################################### - if "TimeHH:MM" in lItem: + if "TimeHH:MMStr" in lItem: #Вид активности - запуск процесса #Сформировать временной штамп, относительно которого надо будет проверять время #часовой пояс пока не учитываем - lActivityDateTime=datetime.datetime.strptime(lItem["TimeHH:MM"],"%H:%M") + lActivityDateTime=datetime.datetime.strptime(lItem["TimeHH:MMStr"],"%H:%M") lActivityDateTime=lActivityDateTime.replace(year=lCurrentDateTime.year,month=lCurrentDateTime.month,day=lCurrentDateTime.day) #Убедиться в том, что время наступило if (