diff --git a/smash/web/api_views/appointment.py b/smash/web/api_views/appointment.py index db8122ed6b31d7e0fb2438b0988e1c3af7c9af63..932ee6ee75be8fe3e54526a33a6ae73bf1da3202 100644 --- a/smash/web/api_views/appointment.py +++ b/smash/web/api_views/appointment.py @@ -1,3 +1,4 @@ +import logging import traceback from datetime import datetime @@ -13,6 +14,8 @@ from web.views.notifications import get_filter_locations, \ get_today_midnight_date, \ get_unfinished_appointments +logger = logging.getLogger(__name__) + @login_required def get_appointments(request, type, min_date, max_date): @@ -76,7 +79,7 @@ def appointments(request, type): "data": data, }) except: - traceback.print_exc() + logger.exception("Problem with getting appointments") return e500_error(request) diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index df1aa3535a35b36a152bafdd782964ae0698c911..c1394a0dc93124e12d5f168e905989c574167baa 100644 --- a/smash/web/api_views/subject.py +++ b/smash/web/api_views/subject.py @@ -1,3 +1,5 @@ +import logging + from django.contrib.auth.decorators import login_required from django.http import JsonResponse @@ -7,6 +9,8 @@ from web.views import e500_error from web.views.notifications import get_subjects_with_no_visit, get_subjects_with_reminder from web.views.subject import SUBJECT_LIST_GENERIC, SUBJECT_LIST_NO_VISIT, SUBJECT_LIST_REQUIRE_CONTACT +logger = logging.getLogger(__name__) + @login_required def cities(request): @@ -101,8 +105,12 @@ def get_subjects_filtered(subjects, filters): elif column == "": pass else: - print "UNKNOWN filter: " - print row + message = "UNKNOWN filter: " + if column is None: + message += "[None]" + else: + message += str(column) + logger.warn(message) return result diff --git a/smash/web/tests/test_VisitAddForm.py b/smash/web/tests/test_VisitAddForm.py index cf3eff33d9f8ced997d061d10f96b52114165435..2a2dfe0c6b6d85ca86fb47cd6946d76df0d32189 100644 --- a/smash/web/tests/test_VisitAddForm.py +++ b/smash/web/tests/test_VisitAddForm.py @@ -22,7 +22,6 @@ class SubjectAddFormTests(TestCase): def test_validation(self): form = VisitAddForm(data=self.sample_data) is_valid = form.is_valid() - print(form.errors) self.assertTrue(is_valid) def test_invalid_validation(self): diff --git a/smash/web/tests/test_view_contact_attempt.py b/smash/web/tests/test_view_contact_attempt.py index 48b09ac930c4c411d56b493c504b420979848a29..6a36fdaaaa2310d8e929e7e0440b05bd414a4197 100644 --- a/smash/web/tests/test_view_contact_attempt.py +++ b/smash/web/tests/test_view_contact_attempt.py @@ -67,6 +67,4 @@ class ContactAttemptViewTests(LoggedInWithWorkerTestCase): kwargs={'subject_id': contact_attempt.subject.id, 'contact_attempt_id': contact_attempt.id}), data=form_data) - print response.content - self.assertEqual(response.status_code, 302) diff --git a/smash/web/views/kit.py b/smash/web/views/kit.py index 4955103d7f6293290e8a2b1fa182e1f82bf672d2..e119ded107c6cea9a79cb9e655a5437f4edd3ec5 100644 --- a/smash/web/views/kit.py +++ b/smash/web/views/kit.py @@ -1,11 +1,9 @@ # coding=utf-8 - import datetime import locale +import logging import platform -import sys import time -import traceback import pytz from django.contrib import messages @@ -23,6 +21,8 @@ from ..forms import KitRequestForm from ..models import AppointmentType, Appointment from ..smash_email import EmailSender +logger = logging.getLogger(__name__) + def get_kit_requests(user, start_date=None, end_date=None): if start_date is None: @@ -167,8 +167,7 @@ class KitRequestEmailSendJob(CronJobBase): try: locale.setlocale(locale.LC_TIME, locale_name) except: - print locale_name - traceback.print_exc(file=sys.stdout) + logger.error("Problem with setting locale: " + locale_name) user_day_of_week_int = int(time.strptime(user_day_of_week, '%A').tm_wday) + 1 current_day_of_week_int = int(datetime.datetime.now().strftime("%w"))