From a41a0a0462fab1ca205c04d314e0e4549a8f76fa Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Fri, 7 Jan 2022 17:01:07 +0300 Subject: [PATCH] def ActivityItemDefAliasModulesLoad - load full python scode from sys.modules in ActivityItem def alias. run when Orchestrator starts --- .../Orchestrator/__Orchestrator__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index b44dd0ab..2775e483 100644 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -1332,6 +1332,22 @@ def ActivityItemDefAliasCreate(inDef, inAliasStr=None, inGSettings = None): inGSettings["ProcessorDict"]["AliasDefDict"][inAliasStr] = inDef return inAliasStr +def ActivityItemDefAliasModulesLoad(): + """ + Load all def from sys.modules... in ActivityItem def alias dict + + :return: None + """ + lL = OrchestratorLoggerGet() + lL.info(f"ActivityItem aliases: start to load sys.modules") + for lModuleItemStr in sys.modules: + lModuleItem = sys.modules[lModuleItemStr] + for lDefItemStr in dir(lModuleItem): + lDefItem = getattr(lModuleItem,lDefItemStr) + if callable(lDefItem) and not lDefItemStr.startswith("_"): + ActivityItemDefAliasCreate(inDef=lDefItem, inAliasStr=f"{lModuleItemStr}.{lDefItemStr}") + lL.info(f"ActivityItem aliases: finish to load sys.modules") + def ActivityItemDefAliasUpdate(inDef, inAliasStr, inGSettings = None): """ Update alias for def (can be used in ActivityItem in field Def). @@ -2541,6 +2557,9 @@ def Orchestrator(inGSettings=None, inDumpRestoreBool = True, inRunAsAdministrato lItemDef = getattr(lModule,lItemDefNameStr) if callable(lItemDef): inGSettings["ProcessorDict"]["AliasDefDict"][lItemDefNameStr]=lItemDef + #Load all defs from sys.modules + ActivityItemDefAliasModulesLoad() + #Инициализация настроечных параметров lDaemonLoopSeconds=gSettingsDict["SchedulerDict"]["CheckIntervalSecFloat"] lDaemonActivityLogDict={} #Словарь отработанных активностей, ключ - кортеж (, , , )