Fix: Properly load config
This commit is contained in:
parent
9a09346a44
commit
357afcd21b
5 changed files with 34 additions and 21 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
|||
# Matemat Changelog
|
||||
|
||||
<!-- BEGIN RELEASE v0.2.1 -->
|
||||
## Version 0.2.1
|
||||
|
||||
Hotfix release
|
||||
|
||||
### Changes
|
||||
|
||||
<!-- BEGIN CHANGES 0.2.1 -->
|
||||
- Fix: Properly load config
|
||||
<!-- END CHANGES 0.2.1 -->
|
||||
|
||||
<!-- END RELEASE v0.2.1 -->
|
||||
|
||||
<!-- BEGIN RELEASE v0.2 -->
|
||||
## Version 0.2
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
|
||||
__version__ = '0.2'
|
||||
__version__ = '0.2.1'
|
||||
|
|
|
@ -18,41 +18,41 @@ from matemat.webserver.pagelets import *
|
|||
def _init(config: Dict[str, Any]):
|
||||
logger = Logger.instance()
|
||||
# Set default values for missing config items
|
||||
if 'InstanceName' not in config:
|
||||
config['InstanceName'] = 'Matemat'
|
||||
if 'InstanceName' not in config['pagelet_variables']:
|
||||
config['pagelet_variables']['InstanceName'] = 'Matemat'
|
||||
logger.warning('Property \'InstanceName\' not set, using \'Matemat\'')
|
||||
if 'UploadDir' not in config:
|
||||
config['UploadDir'] = './static/upload/'
|
||||
if 'UploadDir' not in config['pagelet_variables']:
|
||||
config['pagelet_variables']['UploadDir'] = './static/upload/'
|
||||
logger.warning('Property \'UploadDir\' not set, using \'./static/upload/\'')
|
||||
if 'DatabaseFile' not in config:
|
||||
config['DatabaseFile'] = './matemat.db'
|
||||
if 'DatabaseFile' not in config['pagelet_variables']:
|
||||
config['pagelet_variables']['DatabaseFile'] = './matemat.db'
|
||||
logger.warning('Property \'DatabaseFile\' not set, using \'./matemat.db\'')
|
||||
if 'SmtpSendReceipts' not in config:
|
||||
config['SmtpSendReceipts'] = '0'
|
||||
if 'SmtpSendReceipts' not in config['pagelet_variables']:
|
||||
config['pagelet_variables']['SmtpSendReceipts'] = '0'
|
||||
logger.warning('Property \'SmtpSendReceipts\' not set, using \'0\'')
|
||||
if config['SmtpSendReceipts'] == '1':
|
||||
if 'SmtpFrom' not in config:
|
||||
if config['pagelet_variables']['SmtpSendReceipts'] == '1':
|
||||
if 'SmtpFrom' not in config['pagelet_variables']:
|
||||
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpFrom\' missing.')
|
||||
raise KeyError()
|
||||
if 'SmtpSubj' not in config:
|
||||
if 'SmtpSubj' not in config['pagelet_variables']:
|
||||
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpSubj\' missing.')
|
||||
raise KeyError()
|
||||
if 'SmtpHost' not in config:
|
||||
if 'SmtpHost' not in config['pagelet_variables']:
|
||||
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpHost\' missing.')
|
||||
raise KeyError()
|
||||
if 'SmtpPort' not in config:
|
||||
if 'SmtpPort' not in config['pagelet_variables']:
|
||||
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpPort\' missing.')
|
||||
raise KeyError()
|
||||
if 'SmtpUser' not in config:
|
||||
if 'SmtpUser' not in config['pagelet_variables']:
|
||||
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpUser\' missing.')
|
||||
raise KeyError()
|
||||
if 'SmtpPass' not in config:
|
||||
if 'SmtpPass' not in config['pagelet_variables']:
|
||||
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpPass\' missing.')
|
||||
raise KeyError()
|
||||
if 'SmtpEnforceTLS' not in config:
|
||||
if 'SmtpEnforceTLS' not in config['pagelet_variables']:
|
||||
config['SmtpEnforceTLS'] = '1'
|
||||
logger.warning('Property \'SmtpEnforceTLS\' not set, using \'1\'')
|
||||
with MatematDatabase(config['DatabaseFile']):
|
||||
with MatematDatabase(config['pagelet_variables']['DatabaseFile']):
|
||||
# Connect to the database to create it and perform any schema migrations
|
||||
pass
|
||||
# Initialize Jinaj2 template system
|
||||
|
@ -75,7 +75,7 @@ def main():
|
|||
|
||||
config = get_config()
|
||||
|
||||
_init(get_app_config())
|
||||
_init(config)
|
||||
|
||||
host: str = config['listen']
|
||||
port: int = int(str(config['port']))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
||||
|
||||
pkgname=matemat
|
||||
pkgver=0.2
|
||||
pkgver=0.2.1
|
||||
pkgrel=1
|
||||
arch=('any')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Package: matemat
|
||||
Version: 0.2
|
||||
Version: 0.2.1
|
||||
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
||||
Section: web
|
||||
Priority: optional
|
||||
|
|
Loading…
Reference in a new issue