console/SWSCloudCore/config.py

32 lines
944 B
Python
Raw Normal View History

2016-05-10 02:42:07 +03:00
import sys
import os
from configparser import ConfigParser
2016-05-10 02:42:07 +03:00
2025-01-28 23:38:11 +03:00
__config_file__ = os.getenv('CONFIG', '/etc/nativecloud/config.ini')
2016-05-10 02:42:07 +03:00
# setting file read
config = ConfigParser()
2016-05-10 02:42:07 +03:00
if os.path.exists(__config_file__):
config.read(__config_file__)
if not config.has_section('Application'):
sys.exit(1)
if not config.has_option('Application', 'DEBUG'):
sys.exit(1)
if not config.has_option('Application', 'SECRET_KEY'):
sys.exit(1)
if not config.has_section('Database'):
sys.exit(1)
if not config.has_option('Database', 'name'):
sys.exit(1)
if not config.has_option('Database', 'host'):
sys.exit(1)
if not config.has_option('Database', 'port'):
sys.exit(1)
if not config.has_option('Database', 'user'):
sys.exit(1)
if not config.has_option('Database', 'password'):
sys.exit(1)
else:
2025-01-28 23:38:11 +03:00
sys.exit(f'config file not found: {__config_file__}')