def _load_config_file(path): # type: (str) -> None """Load the given GUI configuration file""" try: exec(open(path).read(), globals(), globals()) # yapf: disable except IOError as e: if e.errno != errno.ENOENT: # No such file or directory raise except Exception as e: raise MKConfigError( _("Cannot read configuration file %s: %s:") % (path, e))
def _load_config_file(path: str) -> None: """Load the given GUI configuration file""" try: with Path(path).open("rb") as f: exec(f.read(), globals(), globals()) except IOError as e: if e.errno != errno.ENOENT: # No such file or directory raise except Exception as e: raise MKConfigError( _("Cannot read configuration file %s: %s:") % (path, e))
def _load_config_file(path): # type: (str) -> None """Load the given GUI configuration file""" try: # TODO: Can be changed to text IO with Python 3 with Path(path).open("rb") as f: exec(f.read(), globals(), globals()) # yapf: disable except IOError as e: if e.errno != errno.ENOENT: # No such file or directory raise except Exception as e: raise MKConfigError(_("Cannot read configuration file %s: %s:") % (path, e))
def check_aggregation_title_uniqueness(aggregations): known_titles: Set[Any] = set() for attrs in aggregations.values(): title = attrs["title"] if title in known_titles: raise MKConfigError( _("Duplicate BI aggregation with the title \"<b>%s</b>\". " "Please check your BI configuration and make sure that within each group no aggregation has " "the same title as any other. Note: you can use arguments in the top level " "aggregation rule, like <tt>Host $HOST$</tt>.") % (escaping.escape_attribute(title))) known_titles.add(title)
def include(filename): if not filename.startswith("/"): filename = cmk.utils.paths.default_config_dir + "/" + filename # Config file is obligatory. An empty example is installed # during setup.sh. Better signal an error then simply ignore # Absence. try: execfile(filename, globals(), globals()) except Exception as e: raise MKConfigError( _("Cannot read configuration file %s: %s:") % (filename, e))
def check_title_uniqueness(forest): # Legacy, will be removed any decade from now # One aggregation cannot be in mutliple groups. known_titles: Set[Any] = set() for aggrs in forest.values(): for aggr in aggrs: title = aggr["title"] if title in known_titles: raise MKConfigError( _("Duplicate BI aggregation with the title \"<b>%s</b>\". " "Please check your BI configuration and make sure that within each group no aggregation has " "the same title as any other. Note: you can use arguments in the top level " "aggregation rule, like <tt>Host $HOST$</tt>.") % (escaping.escape_attribute(title))) known_titles.add(title)