From e956ca5017da642778d1a2eab386215f7636fd4b Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Tue, 23 Jul 2024 13:37:52 -0600 Subject: [PATCH] Add more debug --- app/aws/s3.py | 7 ++----- app/celery/provider_tasks.py | 4 ++-- app/celery/tasks.py | 1 + app/clients/sms/aws_sns.py | 3 ++- app/delivery/send_to_providers.py | 2 ++ app/job/rest.py | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index b844ec134..b57570e29 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -138,15 +138,12 @@ def extract_personalisation(job): print(hilite(f"first_row again: {first_row}")) personalisation = {} job_row = 0 - row_csv_module = csv.reader(job) - for row_module in row_csv_module: - print(hilite(f"CSV MODULE ROW: {row_module}")) - for row in job: - row = row.split(",") + for row in row_csv_module: print(hilite(f"row: {row}")) temp = dict(zip(first_row, row)) + print(hilite(f"temp: {temp}")) personalisation[job_row] = temp job_row = job_row + 1 print(hilite(f"job_row: {job_row}")) diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index 7d32c9326..44bda2b91 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -18,7 +18,7 @@ from app.delivery import send_to_providers from app.enums import NotificationStatus from app.exceptions import NotificationTechnicalFailureException -from app.utils import utc_now +from app.utils import hilite, utc_now # This is the amount of time to wait after sending an sms message before we check the aws logs and look for delivery # receipts @@ -100,7 +100,7 @@ def deliver_sms(self, notification_id): notification = notifications_dao.get_notification_by_id(notification_id) ansi_green = "\033[32m" ansi_reset = "\033[0m" - + print(hilite(f"notification inside of deliver_sms: {notification}")) if not notification: raise NoResultFound() if ( diff --git a/app/celery/tasks.py b/app/celery/tasks.py index f0d036549..17703c5dd 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -170,6 +170,7 @@ def __total_sending_limits_for_job_exceeded(service, job, job_id): def save_sms(self, service_id, notification_id, encrypted_notification, sender_id=None): """Persist notification to db and place notification in queue to send to sns.""" notification = encryption.decrypt(encrypted_notification) + print(hilite(f"notification at the top of save_sms: {notification}")) # SerialisedService and SerialisedTemplate classes are # used here to grab the same service and template from the cache # to improve performance. diff --git a/app/clients/sms/aws_sns.py b/app/clients/sms/aws_sns.py index e1c872665..948a98ed1 100644 --- a/app/clients/sms/aws_sns.py +++ b/app/clients/sms/aws_sns.py @@ -2,6 +2,7 @@ import re from time import monotonic +from app.utils import hilite import botocore import phonenumbers from boto3 import client @@ -54,7 +55,7 @@ def send_sms(self, to, content, reference, sender=None, international=False): to = phonenumbers.format_number( match.number, phonenumbers.PhoneNumberFormat.E164 ) - + print(hilite(f"to in send_sms: {to}")) # See documentation # https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk attributes = { diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index c0d32bf86..5429dbc64 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -86,6 +86,7 @@ def send_sms_to_provider(notification): notification.job_id, notification.job_row_number, ) + print(hilite(f"recipient: {recipient}")) except Exception: # It is our 2facode, maybe key = f"2facode-{notification.id}".replace(" ", "") @@ -108,6 +109,7 @@ def send_sms_to_provider(notification): "sender": notification.reply_to_text, "international": notification.international, } + print(hilite(f"send_sms_kwargs: {send_sms_kwargs}")) db.session.close() # no commit needed as no changes to objects have been made above message_id = provider.send_sms(**send_sms_kwargs) diff --git a/app/job/rest.py b/app/job/rest.py index 85414a29c..eea270e27 100644 --- a/app/job/rest.py +++ b/app/job/rest.py @@ -33,7 +33,7 @@ notifications_filter_schema, unarchived_template_schema, ) -from app.utils import midnight_n_days_ago, pagination_links +from app.utils import hilite, midnight_n_days_ago, pagination_links job_blueprint = Blueprint("job", __name__, url_prefix="/service//job") @@ -172,6 +172,7 @@ def create_job(service_id): raise InvalidRequest("Create job is not allowed: service is inactive ", 403) data = request.get_json() + print(hilite(f"data at the top of create_job: {data}")) original_file_name = data.get("original_file_name") data.update({"service": service_id}) try: