-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
39 lines (30 loc) · 1.16 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import configparser
STORAGE_TYPES = ['aws', 'network']
def parse_conf(conf_file):
config = configparser.ConfigParser()
config.read(conf_file)
storage_type = config.get('Storage', 'type')
if storage_type not in STORAGE_TYPES:
print('Storage type {} is unknown'.format(storage_type))
exit(1)
kwargs = {
'storage_type': storage_type,
'in_frames': config.get('Images', 'in_frames'),
'out_frames': config.get('Images', 'out_frames'),
'img_ext': config.get('Images', 'img_ext'),
}
if storage_type == 'network':
kwargs.update({
'username': config.get('Network', 'username'),
'password': config.get('Network', 'password'),
'hostname': config.get('Network', 'hostname'),
'destination': config.get('Network', 'destination'),
})
elif storage_type == 'aws':
kwargs.update({
'bucket': config.get('AWS', 'bucket'),
'aws_keyid': config.get('AWS', 'aws_access_key_id'),
'aws_accesskey': config.get('AWS', 'aws_secret_access_key'),
'key': config.get('AWS', 'key'),
})
return kwargs