diff options
author | Markus Krogh <markus@nordu.net> | 2017-07-21 14:28:47 +0200 |
---|---|---|
committer | Markus Krogh <markus@nordu.net> | 2017-07-21 14:28:47 +0200 |
commit | d00b0109a611d9c73c1d6d0267c786a19d40d0a8 (patch) | |
tree | 1c27be983a5ce390fa967606c42dda2bda1205ea /maconomy/utils.py | |
parent | 70f08422e643bb859dcad7f21a1d340200beca51 (diff) |
Diffstat (limited to 'maconomy/utils.py')
-rw-r--r-- | maconomy/utils.py | 34 |
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)) |