1
0
Fork 0
forked from s3lph/matemat

Merge branch 'hotfix-config-fix' into 'master'

Fix: Properly load config

See merge request s3lph/matemat!68
This commit is contained in:
s3lph 2020-02-04 17:21:34 +00:00
commit 0dc685ac81
5 changed files with 34 additions and 21 deletions

View file

@ -1,5 +1,18 @@
# Matemat Changelog # 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 --> <!-- BEGIN RELEASE v0.2 -->
## Version 0.2 ## Version 0.2

View file

@ -1,2 +1,2 @@
__version__ = '0.2' __version__ = '0.2.1'

View file

@ -18,41 +18,41 @@ from matemat.webserver.pagelets import *
def _init(config: Dict[str, Any]): def _init(config: Dict[str, Any]):
logger = Logger.instance() logger = Logger.instance()
# Set default values for missing config items # Set default values for missing config items
if 'InstanceName' not in config: if 'InstanceName' not in config['pagelet_variables']:
config['InstanceName'] = 'Matemat' config['pagelet_variables']['InstanceName'] = 'Matemat'
logger.warning('Property \'InstanceName\' not set, using \'Matemat\'') logger.warning('Property \'InstanceName\' not set, using \'Matemat\'')
if 'UploadDir' not in config: if 'UploadDir' not in config['pagelet_variables']:
config['UploadDir'] = './static/upload/' config['pagelet_variables']['UploadDir'] = './static/upload/'
logger.warning('Property \'UploadDir\' not set, using \'./static/upload/\'') logger.warning('Property \'UploadDir\' not set, using \'./static/upload/\'')
if 'DatabaseFile' not in config: if 'DatabaseFile' not in config['pagelet_variables']:
config['DatabaseFile'] = './matemat.db' config['pagelet_variables']['DatabaseFile'] = './matemat.db'
logger.warning('Property \'DatabaseFile\' not set, using \'./matemat.db\'') logger.warning('Property \'DatabaseFile\' not set, using \'./matemat.db\'')
if 'SmtpSendReceipts' not in config: if 'SmtpSendReceipts' not in config['pagelet_variables']:
config['SmtpSendReceipts'] = '0' config['pagelet_variables']['SmtpSendReceipts'] = '0'
logger.warning('Property \'SmtpSendReceipts\' not set, using \'0\'') logger.warning('Property \'SmtpSendReceipts\' not set, using \'0\'')
if config['SmtpSendReceipts'] == '1': if config['pagelet_variables']['SmtpSendReceipts'] == '1':
if 'SmtpFrom' not in config: if 'SmtpFrom' not in config['pagelet_variables']:
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpFrom\' missing.') logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpFrom\' missing.')
raise KeyError() raise KeyError()
if 'SmtpSubj' not in config: if 'SmtpSubj' not in config['pagelet_variables']:
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpSubj\' missing.') logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpSubj\' missing.')
raise KeyError() raise KeyError()
if 'SmtpHost' not in config: if 'SmtpHost' not in config['pagelet_variables']:
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpHost\' missing.') logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpHost\' missing.')
raise KeyError() raise KeyError()
if 'SmtpPort' not in config: if 'SmtpPort' not in config['pagelet_variables']:
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpPort\' missing.') logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpPort\' missing.')
raise KeyError() raise KeyError()
if 'SmtpUser' not in config: if 'SmtpUser' not in config['pagelet_variables']:
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpUser\' missing.') logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpUser\' missing.')
raise KeyError() raise KeyError()
if 'SmtpPass' not in config: if 'SmtpPass' not in config['pagelet_variables']:
logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpPass\' missing.') logger.fatal('\'SmtpSendReceipts\' set to \'1\', but \'SmtpPass\' missing.')
raise KeyError() raise KeyError()
if 'SmtpEnforceTLS' not in config: if 'SmtpEnforceTLS' not in config['pagelet_variables']:
config['SmtpEnforceTLS'] = '1' config['SmtpEnforceTLS'] = '1'
logger.warning('Property \'SmtpEnforceTLS\' not set, using \'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 # Connect to the database to create it and perform any schema migrations
pass pass
# Initialize Jinaj2 template system # Initialize Jinaj2 template system
@ -75,7 +75,7 @@ def main():
config = get_config() config = get_config()
_init(get_app_config()) _init(config)
host: str = config['listen'] host: str = config['listen']
port: int = int(str(config['port'])) port: int = int(str(config['port']))

View file

@ -2,7 +2,7 @@
# Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol> # Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
pkgname=matemat pkgname=matemat
pkgver=0.2 pkgver=0.2.1
pkgrel=1 pkgrel=1
arch=('any') arch=('any')

View file

@ -1,5 +1,5 @@
Package: matemat Package: matemat
Version: 0.2 Version: 0.2.1
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol> Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
Section: web Section: web
Priority: optional Priority: optional