summaryrefslogtreecommitdiff
path: root/jfr_playoff/data/info.py
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/data/info.py')
-rw-r--r--jfr_playoff/data/info.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/jfr_playoff/data/info.py b/jfr_playoff/data/info.py
new file mode 100644
index 0000000..371ac6a
--- /dev/null
+++ b/jfr_playoff/data/info.py
@@ -0,0 +1,29 @@
+from jfr_playoff.logger import PlayoffLogger
+
+
+class ResultInfo(object):
+ def __init__(self, *args):
+ self.clients = self.fill_client_list(*args)
+
+ def fill_client_list(self, settings, database):
+ return []
+
+ def call_client(self, method, default, *args):
+ PlayoffLogger.get('resultinfo').info(
+ 'calling %s on result info clients', method)
+ for client in self.clients:
+ try:
+ ret = getattr(client, method)(*args)
+ PlayoffLogger.get('resultinfo').info(
+ '%s method returned %s', method, ret)
+ return ret
+ except Exception as e:
+ if type(e) in client.get_exceptions(method):
+ PlayoffLogger.get('resultinfo').warning(
+ '%s method raised %s(%s)',
+ method, type(e).__name__, str(e))
+ else:
+ raise
+ PlayoffLogger.get('resultinfo').info(
+ '%s method returning default: %s', method, default)
+ return default