-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
50 lines (38 loc) · 1.16 KB
/
settings.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from os.path import exists
import configparser
# Vars
api_key:str = ''
api_secret:str = ''
bucket_name:str = ''
bucket_region:str = ''
bucket_url:str = ''
endpoint:str = ''
# Initialize config
config = configparser.ConfigParser()
config['SETTINGS'] = {}
def write_config():
section = config['SETTINGS']
global api_key, api_secret, bucket_name, bucket_region, bucket_url, endpoint
section['API Key'] = api_key
section['API Secret'] = api_secret
section['Bucket Name'] = bucket_name
section['Bucket Region'] = bucket_region
section['Bucket URL'] = bucket_url
section['Endpoint'] = endpoint
with open('settings.ini', 'w') as configfile:
config.write(configfile)
def read_config():
config.read('settings.ini')
section = config['SETTINGS']
global api_key, api_secret, bucket_name, bucket_region, bucket_url, endpoint
api_key = section['API Key']
api_secret = section['API Secret']
bucket_name = section['Bucket Name']
bucket_region = section['Bucket Region']
bucket_url = section['Bucket URL']
endpoint = section['Endpoint']
# Check if settings file exists. If not, create it
if not exists('settings.ini'):
write_config()
else:
read_config()