File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
process_tracker/utilities Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11# Settings manager and configuration, both for initialization and reading.
22
33import configparser
4- import io
54import logging
65import os
76from pathlib import Path
7+ import tempfile
88
99from process_tracker .utilities .aws_utilities import AwsUtilities
1010
@@ -109,10 +109,14 @@ def read_config_file(self):
109109 bucket = self .aws_utils .get_s3_bucket (bucket_name = bucket_name )
110110 key = self .aws_utils .determine_file_key (path = self .config_file )
111111
112- cfg = bucket .Object (key ).get ()
113- cfg = io .TextIOWrapper (io .BytesIO (cfg ["Body" ].read ()))
112+ temporary_file = tempfile .NamedTemporaryFile ()
114113
115- self .config .readfp (cfg )
114+ bucket .download_file (key , temporary_file .name )
115+
116+ with open (temporary_file .name , "r" ) as f :
117+ self .config .read_file (f )
118+
119+ temporary_file .close ()
116120
117121 else :
118122
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ def test_read_config_file_s3(self):
7070 expected_keys = ["process_tracker_config.ini" ]
7171 test_bucket = "test_bucket"
7272
73- path = "s3://test_bucket/process_tracker_config.ini"
73+ path = (
74+ "s3://test_bucket/process_tracker_config/SANDBOX/process_tracker_config.ini"
75+ )
76+ # path = "s3://test_bucket/process_tracker_config.ini"
7477
7578 client = boto3 .client (
7679 "s3" ,
You can’t perform that action at this time.
0 commit comments