From 0f52efd742eb9dc6a826feee56cfd0fb1dfc4e2e Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 3 Jan 2025 12:27:00 -0800 Subject: [PATCH 01/10] fix BOM issue again --- app/aws/s3.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index d97c421f2..7ad471ed8 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -402,12 +402,7 @@ def extract_phones(job): phone_index = 0 for item in first_row: # Note: may contain a BOM and look like \ufeffphone number - if item.lower() in [ - "phone number", - "\\ufeffphone number", - "\\ufeffphone number\n", - "phone number\n", - ]: + if item.lower().lstrip("\ufeff") == "phone number": break phone_index = phone_index + 1 @@ -419,7 +414,8 @@ def extract_phones(job): if phone_index >= len(row): phones[job_row] = "Unavailable" current_app.logger.error( - "Corrupt csv file, missing columns or possibly a byte order mark in the file", + f"Corrupt csv file, missing columns or\ + possibly a byte order mark in the file, row looks like {row}", ) else: From a4d8e4fd4cdf455cd366fa8022463a89f802268d Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 07:29:41 -0800 Subject: [PATCH 02/10] pin poetry version to 1.8.5 --- .github/actions/setup-project/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-project/action.yml b/.github/actions/setup-project/action.yml index c095bd595..b2821a5b6 100644 --- a/.github/actions/setup-project/action.yml +++ b/.github/actions/setup-project/action.yml @@ -15,4 +15,4 @@ runs: python-version: "3.12.3" - name: Install poetry shell: bash - run: pip install --upgrade poetry + run: pip install poetry==1.8.5 From 7c8a543629926d9797278651b61cca87e5fbf6e7 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 07:37:21 -0800 Subject: [PATCH 03/10] pin poetry version to 1.8.5 --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index acd31f390..1ffc0a725 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,12 @@ GIT_COMMIT ?= $(shell git rev-parse HEAD) ## DEVELOPMENT +## TODO this line should go under `make generate-version-file` +## poetry self update + .PHONY: bootstrap bootstrap: ## Set up everything to run the app make generate-version-file - poetry self update poetry self add poetry-dotenv-plugin poetry lock --no-update poetry install --sync --no-root From 7b5c8401079a41455872cefc4daa9e67e51c85c5 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:10:13 -0800 Subject: [PATCH 04/10] code review feedback --- app/aws/s3.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index 7ad471ed8..e736cdcb0 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -1,4 +1,6 @@ +import csv import datetime +from io import StringIO import re import time from concurrent.futures import ThreadPoolExecutor @@ -395,21 +397,19 @@ def get_job_from_s3(service_id, job_id): def extract_phones(job): - job = job.split("\r\n") - first_row = job[0] - job.pop(0) - first_row = first_row.split(",") + job_csv_data = StringIO(job) + csv_reader = csv.reader(job_csv_data) + first_row = next(csv_reader) + phone_index = 0 - for item in first_row: - # Note: may contain a BOM and look like \ufeffphone number + for i, item in enumerate(first_row): if item.lower().lstrip("\ufeff") == "phone number": + phone_index = i break - phone_index = phone_index + 1 phones = {} job_row = 0 - for row in job: - row = row.split(",") + for row in csv_reader: if phone_index >= len(row): phones[job_row] = "Unavailable" From 803a29333d7cb20543b1f7edd6bee83505a1ecaa Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:25:13 -0800 Subject: [PATCH 05/10] try oscrypto 1.3.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dc568d89e..bffe8a25a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ marshmallow = "==3.22.0" marshmallow-sqlalchemy = "==1.0.0" newrelic = "*" notifications-python-client = "==10.0.0" -oscrypto = "==1.3.0" +oscrypto = { git = "https://github.com/wbond/oscrypto.git", tag = "v.1.3.1" } packaging = "==24.1" poetry-dotenv-plugin = "==0.2.0" psycopg2-binary = "==2.9.9" From e5e5959db40db33e1de8732cd5af8e02d784dd3f Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:27:54 -0800 Subject: [PATCH 06/10] try oscrypto 1.3.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bffe8a25a..d29ff84f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ marshmallow = "==3.22.0" marshmallow-sqlalchemy = "==1.0.0" newrelic = "*" notifications-python-client = "==10.0.0" -oscrypto = { git = "https://github.com/wbond/oscrypto.git", tag = "v.1.3.1" } +oscrypto = { git = "https://github.com/wbond/oscrypto.git", rev = "1547f53" } packaging = "==24.1" poetry-dotenv-plugin = "==0.2.0" psycopg2-binary = "==2.9.9" From 7088f3b9762d0b276fd07ca3dc5fb540cc675f4d Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:29:44 -0800 Subject: [PATCH 07/10] try oscrypto 1.3.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d29ff84f1..8da60795a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ marshmallow = "==3.22.0" marshmallow-sqlalchemy = "==1.0.0" newrelic = "*" notifications-python-client = "==10.0.0" -oscrypto = { git = "https://github.com/wbond/oscrypto.git", rev = "1547f53" } +oscrypto = { git = "https://github.com/wbond/oscrypto.git" } packaging = "==24.1" poetry-dotenv-plugin = "==0.2.0" psycopg2-binary = "==2.9.9" From 64e0354f01de7cb8d30ae400ada6225d10067757 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:35:32 -0800 Subject: [PATCH 08/10] try oscrypto 1.3.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8da60795a..e65ab47d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ marshmallow = "==3.22.0" marshmallow-sqlalchemy = "==1.0.0" newrelic = "*" notifications-python-client = "==10.0.0" -oscrypto = { git = "https://github.com/wbond/oscrypto.git" } +oscrypto = { git = "https://github.com/wbond/oscrypto.git", rev = "main" } packaging = "==24.1" poetry-dotenv-plugin = "==0.2.0" psycopg2-binary = "==2.9.9" From 879ed2da0a418cdfbc0dff88cb9e9ff54e4df117 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:47:11 -0800 Subject: [PATCH 09/10] ugh specify rev --- poetry.lock | 14 +++++++++----- pyproject.toml | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index e0096a7de..fadc6cde7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2829,14 +2829,18 @@ version = "1.3.0" description = "TLS (SSL) sockets, key generation, encryption, decryption, signing, verification and KDFs using the OS crypto libraries. Does not require a compiler, and relies on the OS for patching. Works on Windows, OS X and Linux/BSD." optional = false python-versions = "*" -files = [ - {file = "oscrypto-1.3.0-py2.py3-none-any.whl", hash = "sha256:2b2f1d2d42ec152ca90ccb5682f3e051fb55986e1b170ebde472b133713e7085"}, - {file = "oscrypto-1.3.0.tar.gz", hash = "sha256:6f5fef59cb5b3708321db7cca56aed8ad7e662853351e7991fcf60ec606d47a4"}, -] +files = [] +develop = false [package.dependencies] asn1crypto = ">=1.5.1" +[package.source] +type = "git" +url = "https://github.com/wbond/oscrypto.git" +reference = "1547f53" +resolved_reference = "1547f535001ba568b239b8797465536759c742a3" + [[package]] name = "packageurl-python" version = "0.16.0" @@ -4947,4 +4951,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.12.2" -content-hash = "271d8e0f25856f45970e5a9cc3b8871a01b732226ab3ed68ea426912b5117fcf" +content-hash = "81a109693e74d2ffa3be7098e629050f25090c6a08bab57056b9a4a35283ea6f" diff --git a/pyproject.toml b/pyproject.toml index e65ab47d7..d29ff84f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ marshmallow = "==3.22.0" marshmallow-sqlalchemy = "==1.0.0" newrelic = "*" notifications-python-client = "==10.0.0" -oscrypto = { git = "https://github.com/wbond/oscrypto.git", rev = "main" } +oscrypto = { git = "https://github.com/wbond/oscrypto.git", rev = "1547f53" } packaging = "==24.1" poetry-dotenv-plugin = "==0.2.0" psycopg2-binary = "==2.9.9" From 7fab332ab9e884629f4de77dfa6d207cc75a86c9 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 6 Jan 2025 13:50:10 -0800 Subject: [PATCH 10/10] fix isort --- app/aws/s3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index e736cdcb0..c33366a2c 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -1,9 +1,9 @@ import csv import datetime -from io import StringIO import re import time from concurrent.futures import ThreadPoolExecutor +from io import StringIO import botocore from boto3 import Session