[checkmk-commits] cmk.special_agents.utils: DataCache: allow more arguments

Moritz Kiemer mo at mathias-kettner.de
Tue May 7 09:50:43 CEST 2019


Module: check_mk
Branch: master
Commit: 6b146239b460c64e28143beb4808a25626ff7c94
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6b146239b460c64e28143beb4808a25626ff7c94

Author: Moritz Kiemer <mo at mathias-kettner.de>
Date:   Mon May  6 07:35:24 2019 +0200

cmk.special_agents.utils: DataCache: allow more arguments

Change-Id: Iff729ae111d5e53619c01f7cfefdc997bff23290

---

 cmk/special_agents/utils.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/cmk/special_agents/utils.py b/cmk/special_agents/utils.py
index 60febc6..b0e8ff3 100644
--- a/cmk/special_agents/utils.py
+++ b/cmk/special_agents/utils.py
@@ -127,14 +127,14 @@ class DataCache(object):
         pass
 
     @abc.abstractmethod
-    def get_validity_from_args(self, args):
+    def get_validity_from_args(self, *args):
         """
         Decide whether we need to update the cache due to new arguments
         """
         pass
 
     @abc.abstractmethod
-    def get_live_data(self, args):
+    def get_live_data(self, *args):
         """
         This is the function that will be called if no cached data can be found.
         """
@@ -187,8 +187,9 @@ class DataCache(object):
             raise
         return content
 
-    def get_data(self, args, use_cache=True):
-        if (use_cache and self.get_validity_from_args(args) and self._cache_is_valid()):
+    def get_data(self, *args, **kwargs):
+        use_cache = kwargs.pop('use_cache', True)
+        if (use_cache and self.get_validity_from_args(*args) and self._cache_is_valid()):
             try:
                 return self.get_cached_data()
             except (OSError, IOError, ValueError) as exc:
@@ -196,7 +197,7 @@ class DataCache(object):
                 if self.debug:
                     raise
 
-        live_data = self.get_live_data(args)
+        live_data = self.get_live_data(*args)
         if use_cache:
             try:
                 self._write_to_cache(live_data)



More information about the checkmk-commits mailing list