File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
process_tracker/utilities Expand file tree Collapse file tree 2 files changed +8
-9
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
45import logging
56import os
67from pathlib import Path
7- import tempfile
88
99from process_tracker .utilities .aws_utilities import AwsUtilities
1010
@@ -68,6 +68,10 @@ def __init__(self, config_location=None):
6868
6969 if exists :
7070 self .read_config_file ()
71+ else :
72+ self .logger .info ("Config file does not exist." )
73+ if not cloud :
74+ self .create_config_file ()
7175
7276 def create_config_file (self ):
7377 """
@@ -100,17 +104,15 @@ def read_config_file(self):
100104 path = self .config_path
101105 ) and self .aws_utils .determine_s3_file_exists (path = self .config_file ):
102106
103- temp_file = tempfile .NamedTemporaryFile ()
104107 bucket_name = self .aws_utils .determine_bucket_name (path = self .config_path )
105108
106109 bucket = self .aws_utils .get_s3_bucket (bucket_name = bucket_name )
107110 key = self .aws_utils .determine_file_key (path = self .config_file )
108111
109- bucket .download_file (key , temp_file .name )
112+ cfg = bucket .Object (key ).get ()
113+ cfg = io .TextIOWrapper (io .BytesIO (cfg ["Body" ].read ()))
110114
111- with open (temp_file .name , "r" ) as f :
112- self .config .readfp (f )
113- temp_file .close ()
115+ self .config .readfp (cfg )
114116
115117 else :
116118
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ def setUpClass(cls):
1717
1818 cls .config = configparser .ConfigParser (allow_no_value = True )
1919
20- @unittest .skip # Need to fix SettingsManager for this to work right.
2120 def test_config_location_set (self ):
2221 """
2322 Testing that if config_location is set that the path is used instead of setting to home directory.
@@ -32,7 +31,6 @@ def test_config_location_set(self):
3231
3332 self .assertEqual (expected_result , given_result )
3433
35- @unittest .skip # Need to fix SettingsManager for this to work right.
3634 def test_config_location_s3 (self ):
3735 """
3836 Testing that if config_location is set and the path is an s3 file/location, use that instead of the home
@@ -46,7 +44,6 @@ def test_config_location_s3(self):
4644
4745 self .assertEqual (expected_result , given_result )
4846
49- @unittest .skip # Need to fix SettingsManager for this to work right.
5047 def test_create_config_file (self ):
5148 """
5249 Testing that if the config file does not exist, it is created.
You can’t perform that action at this time.
0 commit comments