summaryrefslogtreecommitdiff
path: root/maconomy/utils.py
diff options
context:
space:
mode:
authorMarkus Krogh <markus@nordu.net>2017-07-21 14:28:47 +0200
committerMarkus Krogh <markus@nordu.net>2017-07-21 14:28:47 +0200
commitd00b0109a611d9c73c1d6d0267c786a19d40d0a8 (patch)
tree1c27be983a5ce390fa967606c42dda2bda1205ea /maconomy/utils.py
parent70f08422e643bb859dcad7f21a1d340200beca51 (diff)
Adding sentryHEADmaster
Diffstat (limited to 'maconomy/utils.py')
-rw-r--r--maconomy/utils.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/maconomy/utils.py b/maconomy/utils.py
index de5ccdd..9092a2d 100644
--- a/maconomy/utils.py
+++ b/maconomy/utils.py
@@ -1,5 +1,8 @@
from collections import defaultdict
import datetime
+from raven import Client
+
+client = None
def per_manager(timesheets):
@@ -18,3 +21,34 @@ def employees(timesheets):
def previous_monday(date=None):
today = date or datetime.date.today()
return today + datetime.timedelta(days=-today.weekday(), weeks=-1)
+
+
+def is_present(what):
+ return what and what.strip()
+
+
+def is_empty(what):
+ return not is_present(what)
+
+
+def sentry_log(msg, extra={}):
+ if client:
+ try:
+ client.captureMessage(msg, extra=extra)
+ except:
+ client.captureException()
+
+
+def sentry_exception():
+ if client:
+ client.captureException()
+
+
+def sentry(config):
+ if config.has_option('sentry', 'dsn'):
+ try:
+ dsn = config.get('sentry', 'dsn')
+ global client
+ client = Client(dsn)
+ except Exception as e:
+ print(str(e))