adjust for cluster deployment
This commit is contained in:
31
src/pv_controller/config.py
Normal file
31
src/pv_controller/config.py
Normal file
@ -0,0 +1,31 @@
|
||||
import os
|
||||
|
||||
class Config:
|
||||
OPTIONS = {
|
||||
'mqtt': [ 'login',
|
||||
'password',
|
||||
'ca',
|
||||
'cert',
|
||||
'key',
|
||||
'broker',
|
||||
'port',
|
||||
'meterPublishTopic',
|
||||
'meterPublishPeriod',
|
||||
'relaisSubscribeTopic' ],
|
||||
'modbus': [ 'gateway' ]
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
self.values = {}
|
||||
for section, keys in OPTIONS:
|
||||
self.values[section] = {}
|
||||
for key in keys:
|
||||
varname = f"{section}__{key}".upper()
|
||||
try:
|
||||
self.values[section][key] = os.environ[varname]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def __getitem__(self, section):
|
||||
return self.values[index]
|
||||
|
Reference in New Issue
Block a user