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 1
1
# Settings manager and configuration, both for initialization and reading.
2
2
3
3
import configparser
4
+ import io
4
5
import logging
5
6
import os
6
7
from pathlib import Path
7
- import tempfile
8
8
9
9
from process_tracker .utilities .aws_utilities import AwsUtilities
10
10
@@ -68,6 +68,10 @@ def __init__(self, config_location=None):
68
68
69
69
if exists :
70
70
self .read_config_file ()
71
+ else :
72
+ self .logger .info ("Config file does not exist." )
73
+ if not cloud :
74
+ self .create_config_file ()
71
75
72
76
def create_config_file (self ):
73
77
"""
@@ -100,17 +104,15 @@ def read_config_file(self):
100
104
path = self .config_path
101
105
) and self .aws_utils .determine_s3_file_exists (path = self .config_file ):
102
106
103
- temp_file = tempfile .NamedTemporaryFile ()
104
107
bucket_name = self .aws_utils .determine_bucket_name (path = self .config_path )
105
108
106
109
bucket = self .aws_utils .get_s3_bucket (bucket_name = bucket_name )
107
110
key = self .aws_utils .determine_file_key (path = self .config_file )
108
111
109
- bucket .download_file (key , temp_file .name )
112
+ cfg = bucket .Object (key ).get ()
113
+ cfg = io .TextIOWrapper (io .BytesIO (cfg ["Body" ].read ()))
110
114
111
- with open (temp_file .name , "r" ) as f :
112
- self .config .readfp (f )
113
- temp_file .close ()
115
+ self .config .readfp (cfg )
114
116
115
117
else :
116
118
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ def setUpClass(cls):
17
17
18
18
cls .config = configparser .ConfigParser (allow_no_value = True )
19
19
20
- @unittest .skip # Need to fix SettingsManager for this to work right.
21
20
def test_config_location_set (self ):
22
21
"""
23
22
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):
32
31
33
32
self .assertEqual (expected_result , given_result )
34
33
35
- @unittest .skip # Need to fix SettingsManager for this to work right.
36
34
def test_config_location_s3 (self ):
37
35
"""
38
36
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):
46
44
47
45
self .assertEqual (expected_result , given_result )
48
46
49
- @unittest .skip # Need to fix SettingsManager for this to work right.
50
47
def test_create_config_file (self ):
51
48
"""
52
49
Testing that if the config file does not exist, it is created.
You can’t perform that action at this time.
0 commit comments