From d00b0109a611d9c73c1d6d0267c786a19d40d0a8 Mon Sep 17 00:00:00 2001 From: Markus Krogh Date: Fri, 21 Jul 2017 14:28:47 +0200 Subject: Adding sentry --- maconomy_hours.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'maconomy_hours.py') diff --git a/maconomy_hours.py b/maconomy_hours.py index 608d502..4b20c7f 100644 --- a/maconomy_hours.py +++ b/maconomy_hours.py @@ -1,7 +1,6 @@ from maconomy import cli, create_db, TimeRegistrationRepository, Mailer from maconomy.views import EmployeeEmailView, ManagerEmailView, CEOEmailView from maconomy import utils -from collections import defaultdict def main(config, options): @@ -18,6 +17,9 @@ def main(config, options): summary(timesheets) else: normal(timesheets, config, mailer) + missing_mail = [ts.employee for ts in timesheets if utils.is_empty(ts.employee.email)] + if missing_mail: + utils.sentry_log("Employees missing emails", {'emplyees': [str(e) for e in missing_mail]}) # Close stuff if mailer: @@ -30,18 +32,17 @@ def normal(timesheets, config, mailer): view = EmployeeEmailView(config) for timesheet in timesheets: if not timesheet.is_submitted(): - mail = view.render(timesheet) + mail = view.render(timesheet) subject = u"Timesheet reminder for {}".format(timesheet.employee) to = timesheet.employee.email if mailer: if to and to.strip(): mailer.send(to, subject, mail) - else: - print(u"No email for: {}".format(timesheet.employee)) else: print(subject) print(mail) + def manager(timesheets, config, mailer): view = ManagerEmailView(config) # extract employees for manager email lookup @@ -84,4 +85,5 @@ def summary(timesheets): if __name__ == '__main__': args = cli.parse() config = cli.load_config(args.config) + utils.sentry(config) main(config, args) -- cgit v1.1