Skip to content

Commit

Permalink
Trying for 0.4.4
Browse files Browse the repository at this point in the history
Issue with config files and lambda remained.  Trying another method to
work with it.
  • Loading branch information
OpenDataAlex committed Jun 24, 2019
1 parent 4bd793f commit 0be2f1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions process_tracker/utilities/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Settings manager and configuration, both for initialization and reading.

import configparser
import io
import logging
import os
from pathlib import Path
import tempfile

from process_tracker.utilities.aws_utilities import AwsUtilities

Expand Down Expand Up @@ -109,10 +109,14 @@ def read_config_file(self):
bucket = self.aws_utils.get_s3_bucket(bucket_name=bucket_name)
key = self.aws_utils.determine_file_key(path=self.config_file)

cfg = bucket.Object(key).get()
cfg = io.TextIOWrapper(io.BytesIO(cfg["Body"].read()))
temporary_file = tempfile.NamedTemporaryFile()

self.config.readfp(cfg)
bucket.download_file(key, temporary_file.name)

with open(temporary_file.name, "r") as f:
self.config.read_file(f)

temporary_file.close()

else:

Expand Down
5 changes: 4 additions & 1 deletion tests/utilities/test_settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ def test_read_config_file_s3(self):
expected_keys = ["process_tracker_config.ini"]
test_bucket = "test_bucket"

path = "s3://test_bucket/process_tracker_config.ini"
path = (
"s3://test_bucket/process_tracker_config/SANDBOX/process_tracker_config.ini"
)
# path = "s3://test_bucket/process_tracker_config.ini"

client = boto3.client(
"s3",
Expand Down

0 comments on commit 0be2f1c

Please sign in to comment.