From d2a43043210245406eab25d6cefc2a7593e58896 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 15 Jan 2024 08:43:46 -0500 Subject: [PATCH] fix: utf8 encoding check was still using NamedTemporaryFile technique that was supplanted by temporary directory approach introduced in https://github.com/dathere/datapusher-plus/pull/117/files --- datapusher/jobs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/datapusher/jobs.py b/datapusher/jobs.py index bdb3097..88f64f8 100644 --- a/datapusher/jobs.py +++ b/datapusher/jobs.py @@ -665,12 +665,13 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None): "Normalizing/UTF-8 transcoding {} to CSV...".format(resource_format) ) - qsv_input_utf_8_encoded_csv = tempfile.NamedTemporaryFile(suffix=".csv") + qsv_input_utf_8_encoded_csv = os.path.join(temp_dir, 'qsv_input_utf_8_encoded.csv') + # using uchardet to determine encoding file_encoding = subprocess.run( [ "uchardet", - tmp.name + tmp ], check=True, capture_output=True, @@ -691,9 +692,9 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None): file_encoding.stdout, "-t", "UTF-8", - tmp.name, + tmp, "--output", - qsv_input_utf_8_encoded_csv.name, + qsv_input_utf_8_encoded_csv, ], check=True, ) @@ -708,7 +709,7 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None): [ qsv_bin, "input", - qsv_input_utf_8_encoded_csv.name, + qsv_input_utf_8_encoded_csv, "--trim-headers", "--output", qsv_input_csv,