diff --git a/app/aws/s3.py b/app/aws/s3.py index 9466e6cce..b57570e29 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -1,5 +1,7 @@ import re +import csv +from app.utils import hilite import botocore from boto3 import Session from expiringdict import ExpiringDict @@ -124,17 +126,28 @@ def extract_phones(job): def extract_personalisation(job): + print(hilite(f"job type: {type(job)}")) + print(hilite(f"Job? {job}")) + job = job.split("\r\n") + print(hilite(f"job after first split: {job}")) first_row = job[0] + print(hilite(f"first_row: {first_row}")) job.pop(0) first_row = first_row.split(",") + print(hilite(f"first_row again: {first_row}")) personalisation = {} job_row = 0 - for row in job: - row = row.split(",") + row_csv_module = csv.reader(job) + + 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}")) + print(hilite(f"personalisation: {personalisation}")) return personalisation @@ -190,6 +203,7 @@ def get_personalisation_from_s3(service_id, job_id, job_row_number): job = JOBS.get(job_id) if job is None: job = get_job_from_s3(service_id, job_id) + print(hilite(f"job at the beginning: {job}")) JOBS[job_id] = job incr_jobs_cache_misses() else: 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: diff --git a/poetry.lock b/poetry.lock index e5a07c733..1e10ead84 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2098,9 +2098,13 @@ files = [ {file = "lxml-5.2.2-cp36-cp36m-win_amd64.whl", hash = "sha256:edcfa83e03370032a489430215c1e7783128808fd3e2e0a3225deee278585196"}, {file = "lxml-5.2.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:28bf95177400066596cdbcfc933312493799382879da504633d16cf60bba735b"}, {file = "lxml-5.2.2-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3a745cc98d504d5bd2c19b10c79c61c7c3df9222629f1b6210c0368177589fb8"}, + {file = "lxml-5.2.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b590b39ef90c6b22ec0be925b211298e810b4856909c8ca60d27ffbca6c12e6"}, {file = "lxml-5.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b336b0416828022bfd5a2e3083e7f5ba54b96242159f83c7e3eebaec752f1716"}, + {file = "lxml-5.2.2-cp37-cp37m-manylinux_2_28_aarch64.whl", hash = "sha256:c2faf60c583af0d135e853c86ac2735ce178f0e338a3c7f9ae8f622fd2eb788c"}, {file = "lxml-5.2.2-cp37-cp37m-manylinux_2_28_x86_64.whl", hash = "sha256:4bc6cb140a7a0ad1f7bc37e018d0ed690b7b6520ade518285dc3171f7a117905"}, + {file = "lxml-5.2.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7ff762670cada8e05b32bf1e4dc50b140790909caa8303cfddc4d702b71ea184"}, {file = "lxml-5.2.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:57f0a0bbc9868e10ebe874e9f129d2917750adf008fe7b9c1598c0fbbfdde6a6"}, + {file = "lxml-5.2.2-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:a6d2092797b388342c1bc932077ad232f914351932353e2e8706851c870bca1f"}, {file = "lxml-5.2.2-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:60499fe961b21264e17a471ec296dcbf4365fbea611bf9e303ab69db7159ce61"}, {file = "lxml-5.2.2-cp37-cp37m-win32.whl", hash = "sha256:d9b342c76003c6b9336a80efcc766748a333573abf9350f4094ee46b006ec18f"}, {file = "lxml-5.2.2-cp37-cp37m-win_amd64.whl", hash = "sha256:b16db2770517b8799c79aa80f4053cd6f8b716f21f8aca962725a9565ce3ee40"}, @@ -2489,7 +2493,6 @@ files = [ {file = "msgpack-1.0.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fbb160554e319f7b22ecf530a80a3ff496d38e8e07ae763b9e82fadfe96f273"}, {file = "msgpack-1.0.8-cp39-cp39-win32.whl", hash = "sha256:f9af38a89b6a5c04b7d18c492c8ccf2aee7048aff1ce8437c4683bb5a1df893d"}, {file = "msgpack-1.0.8-cp39-cp39-win_amd64.whl", hash = "sha256:ed59dd52075f8fc91da6053b12e8c89e37aa043f8986efd89e61fae69dc1b011"}, - {file = "msgpack-1.0.8-py3-none-any.whl", hash = "sha256:24f727df1e20b9876fa6e95f840a2a2651e34c0ad147676356f4bf5fbb0206ca"}, {file = "msgpack-1.0.8.tar.gz", hash = "sha256:95c02b0e27e706e48d0e5426d1710ca78e0f0628d6e89d5b5a5b91a5f12274f3"}, ]