Module: check_mk
Branch: master
Commit: dd720d3500d248eba5403ad2dcec64ad2145c63c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd720d3500d248…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Oct 9 09:37:06 2014 +0200
Repair comments in config module
---
web/htdocs/config.py | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index e329b7b..fe1eeb7 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -24,21 +24,12 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# The following debug code can be used to tackle a mod_python
-# problem when using the local hierarchy for plugins that refer
-# to the config module.
-# import time, os
-# fn = "/tmp/config.load.%d" % os.getpid()
-# if os.path.exists(fn):
-# raise Exception("Mist: config zweimal geladen!!")
-#
-# file(fn, "a").write("[%d] Geladen: %s\n" % (os.getpid(), time.time()))
-
import os, pprint, glob
from lib import *
-# In case we start standalone and outside an check_mk enviroment,
-# we have another path for the defaults
+# In case we start standalone and outside a Check_MK enviroment,
+# we have another path for the defaults.
+# FIXME: Do we need thus rubbish anymore?
try:
import defaults
except:
@@ -46,6 +37,7 @@ except:
# Python 2.3 does not have 'set' in normal namespace.
# But it can be imported from 'sets'
+# FIXME: We should officially drop Python 2.3 support
try:
set()
except NameError:
@@ -110,7 +102,7 @@ aggregation_functions = {}
#.
-# .----------------------------------------------------------------------.
+# .--Functions-----------------------------------------------------------.
# | _____ _ _ |
# | | ___| _ _ __ ___| |_(_) ___ _ __ ___ |
# | | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
@@ -428,6 +420,7 @@ def save_user_file(name, content, unlock = False):
raise MKConfigError(_("Cannot save %s options for user <b>%s</b> into <b>%s</b>: %s") % \
(name, user_id, path, e))
+#.
# .--Sites---------------------------------------------------------------.
# | ____ _ _ |
# | / ___|(_) |_ ___ ___ |
Module: check_mk
Branch: master
Commit: cea80ffb8d19e46c811ec843330e59e1880508c0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cea80ffb8d19e4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Oct 8 16:05:18 2014 +0200
visuals: new helper function for getting filter headers
---
web/htdocs/visuals.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 689875b..ce9f581 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -912,6 +912,32 @@ def add_context_to_uri_vars(visual, only_infos=None, only_count=False):
html.set_var(uri_varname, value)
+# Compute Livestatus-Filters based on a given context. Returns
+# the only_sites list and a string with the filter headers
+def get_filter_headers(datasource, context):
+ # Prepare Filter headers for Livestatus
+ filter_headers = ""
+ only_sites = None
+ html.stash_vars()
+ for filter_name, filter_vars in context.items():
+ # first set the HTML variables. Sorry - the filters need this
+ if type(filter_vars) == dict: # this is a multi-context filter
+ for uri_varname, value in filter_vars.items():
+ html.set_var(uri_varname, value)
+ else:
+ html.set_var(filter_name, filter_vars)
+
+ # Now compute filter headers for all infos of the used datasource
+ our_infos = datasource["infos"]
+ for filter_name, filter_object in multisite_filters.items():
+ if filter_object.info in our_infos:
+ header = filter_object.filter(datasource["table"])
+ if header.startswith("Sites:"):
+ only_sites = header.strip().split(" ")[1:]
+ else:
+ filter_headers += header
+ html.unstash_vars()
+ return filter_headers, only_sites
#.