Skip to content

Commit 0be2f1c

Browse files
committed
Trying for 0.4.4
Issue with config files and lambda remained. Trying another method to work with it.
1 parent 4bd793f commit 0be2f1c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

process_tracker/utilities/settings.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Settings manager and configuration, both for initialization and reading.
22

33
import configparser
4-
import io
54
import logging
65
import os
76
from pathlib import Path
7+
import tempfile
88

99
from 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

tests/utilities/test_settings_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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",

0 commit comments

Comments
 (0)