diff --git a/stateengine/StateEngineAction.py b/stateengine/StateEngineAction.py index 6848f21a5..e2b7f41dc 100755 --- a/stateengine/StateEngineAction.py +++ b/stateengine/StateEngineAction.py @@ -569,12 +569,12 @@ def _waitforexecute(self, state, actionname: str, namevar: str = "", repeat_text 'previousstate_condition': previousstate_condition, 'state': state}, next=next_run) - def _delayed_execute(self, actionname: str, namevar: str = "", repeat_text: str = "", value=None, current_condition=None, previous_condition=None, previousstate_condition=None, state=None): + def _delayed_execute(self, actionname: str, namevar: str = "", repeat_text: str = "", value=None, current_condition=None, previous_condition=None, previousstate_condition=None, state=None, caller=None): if state: - self._log_debug("Putting delayed action '{}' from state '{}' into queue.", namevar, state) + self._log_debug("Putting delayed action '{}' from state '{}' into queue. Caller: {}", namevar, state, caller) self.__queue.put(["delayedaction", self, actionname, namevar, repeat_text, value, current_condition, previous_condition, previousstate_condition, state]) else: - self._log_debug("Putting delayed action '{}' into queue.", namevar) + self._log_debug("Putting delayed action '{}' into queue. Caller: {}", namevar, caller) self.__queue.put(["delayedaction", self, actionname, namevar, repeat_text, value, current_condition, previous_condition, previousstate_condition]) if not self._abitem.update_lock.locked(): self._log_debug("Running queue") diff --git a/stateengine/StateEngineFunctions.py b/stateengine/StateEngineFunctions.py index 6b90c0822..dc66feee0 100755 --- a/stateengine/StateEngineFunctions.py +++ b/stateengine/StateEngineFunctions.py @@ -83,11 +83,11 @@ def manual_item_update_eval(self, item_id, caller=None, source=None): self.logger.error("manual_item_update_item: se_manual_logitem {0} not found!".format(elog_item_id)) elog = StateEngineLogger.SeLoggerDummy() else: - elog = StateEngineLogger.SeLogger.create(elog_item) + elog = StateEngineLogger.SeLogger.create(elog_item, manual=True) else: elog = StateEngineLogger.SeLoggerDummy() elog.header("manual_item_update_eval") - elog.info("running for item '{0}' source '{1}' caller '{2}'", item_id, caller, source) + elog.info("running for item '{0}' source '{1}' caller '{2}'", item_id, source, caller) retval_no_trigger = item() retval_trigger = not item() @@ -121,7 +121,9 @@ def manual_item_update_eval(self, item_id, caller=None, source=None): result = entry.match(original) elog.info("Checking regex result {}", result) if result is not None: - elog.info("{0}: matching. Writing value {1}", entry, retval_no_trigger) + elog.info("{0}: matching.", entry) + elog.decrease_indent() + elog.info("Writing value {0}", retval_no_trigger) return retval_no_trigger elog.info("{0}: not matching", entry) elog.decrease_indent() @@ -144,7 +146,9 @@ def manual_item_update_eval(self, item_id, caller=None, source=None): result = entry.match(original) elog.info("Checking regex result {}", result) if result is not None: - elog.info("{0}: matching. Writing value {1}", entry, retval_no_trigger) + elog.info("{0}: matching.", entry) + elog.decrease_indent() + elog.info("Writing value {0}", retval_no_trigger) return retval_no_trigger elog.info("{0}: not matching", entry) elog.decrease_indent() @@ -166,7 +170,9 @@ def manual_item_update_eval(self, item_id, caller=None, source=None): result = entry.match(original) elog.info("Checking regex result {}", result) if result is not None: - elog.info("{0}: matching. Writing value {1}", entry, retval_trigger) + elog.info("{0}: matching.", entry) + elog.decrease_indent() + elog.info("Writing value {0}", retval_no_trigger) return retval_trigger elog.info("{0}: not matching", entry) elog.decrease_indent() diff --git a/stateengine/StateEngineItem.py b/stateengine/StateEngineItem.py index 1ef03cfc5..669898e55 100755 --- a/stateengine/StateEngineItem.py +++ b/stateengine/StateEngineItem.py @@ -524,6 +524,8 @@ def run_queue(self): # Find out what initially caused the update to trigger if the caller is "Eval" orig_caller, orig_source, orig_item = StateEngineTools.get_original_caller(self.__logger, caller, source, item) + if orig_item is None: + orig_item = item if orig_caller != caller: text = "{0} initially triggered by {1} (item={2} source={3} value={4})." self.__logger.debug(text, caller, orig_caller, orig_item.property.path, diff --git a/stateengine/StateEngineLogger.py b/stateengine/StateEngineLogger.py index acf5460f5..07eabac00 100755 --- a/stateengine/StateEngineLogger.py +++ b/stateengine/StateEngineLogger.py @@ -122,17 +122,20 @@ def remove_old_logfiles(): # Return SeLogger instance for given item # item: item for which the detailed log is @staticmethod - def create(item): - return SeLogger(item) + def create(item, manual=False): + return SeLogger(item, manual) # Constructor # item: item for which the detailed log is (used as part of file name) - def __init__(self, item): + def __init__(self, item, manual=False): self.logger = logging.getLogger('stateengine.{}'.format(item.property.path)) self.__name = 'stateengine.{}'.format(item.property.path) self.__section = item.property.path.replace(".", "_").replace("/", "") self.__indentlevel = 0 - self.__log_level_as_num = 0 + if manual: + self.__log_level_as_num = 2 + else: + self.__log_level_as_num = 0 self.__logmaxage = None self.__date = None self.__logerror = False diff --git a/stateengine/StateEngineTools.py b/stateengine/StateEngineTools.py index da3f9c4af..23703918b 100755 --- a/stateengine/StateEngineTools.py +++ b/stateengine/StateEngineTools.py @@ -124,7 +124,7 @@ def parse_relative(evalstr, begintag, endtags): rel = rest[:rest.find(endtag)] rest = rest[rest.find(endtag)+len(endtag):] if 'property' in endtag: - rest1 = re.split('( |\+|-|\*|/)', rest, 1) + rest1 = re.split('([ +\-*/])', rest, 1) rest = ''.join(rest1[1:]) pref += "se_eval.get_relative_itemproperty('{}', '{}')".format(rel, rest1[0]) elif '()' in endtag: @@ -333,10 +333,10 @@ def get_original_caller(elog, caller, source, item=None, eval_keyword=['Eval'], original_source = source else: original_source = "None" - while original_caller in eval_keyword: + while partition_strip(original_caller, ":")[0] in eval_keyword: original_item = itemsApi.return_item(original_source) if original_item is None: - elog.warning("get_caller({0}, {1}): original item not found", caller, source) + elog.info("get_caller({0}, {1}): original item not found", caller, source) break original_manipulated_by = original_item.property.last_update_by if eval_type == "update" else \ original_item.property.last_change_by diff --git a/stateengine/webif/templates/visu.html b/stateengine/webif/templates/visu.html index d5a076db3..11ea42a7b 100755 --- a/stateengine/webif/templates/visu.html +++ b/stateengine/webif/templates/visu.html @@ -51,9 +51,6 @@ {% endblock pluginstyles %} {% block pluginscripts %} {% endblock pluginscripts %}