import configparser import sys import os from etcd_wrapper import EtcdWrapper from ldap_manager import LdapManager config_file = os.environ.get('meow-pay-config-file', default='pay.conf') config = configparser.ConfigParser(allow_no_value=True) try: successfully_read_files = config.read(config_file) except configparser.Error as err: sys.exit(err) if not successfully_read_files: sys.exit(f'Config file {config_file} couldn\'t be read.') try: etcd_client = EtcdWrapper( host=config.get('etcd', 'host'), port=config.get('etcd', 'port'), ca_cert=config.get('etcd', 'ca_cert'), cert_key=config.get('etcd', 'cert_key'), cert_cert=config.get('etcd', 'cert_cert') ) ldap_manager = LdapManager( server=config.get('ldap', 'server'), admin_dn=config.get('ldap', 'admin_dn'), admin_password=config.get('ldap', 'admin_password') ) except configparser.Error as err: sys.exit(f'{err} in config file {config_file}.')