summaryrefslogtreecommitdiff
path: root/maconomy/utils.py
diff options
context:
space:
mode:
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))