From 357afcd21b4ec7877fc96202026cf953caa09208 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 4 Feb 2020 18:19:57 +0100 Subject: [PATCH] Fix: Properly load config --- CHANGELOG.md | 13 ++++++++++ matemat/__init__.py | 2 +- matemat/__main__.py | 36 +++++++++++++-------------- package/archlinux/PKGBUILD | 2 +- package/debian/matemat/DEBIAN/control | 2 +- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9a2aed..20873ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Matemat Changelog + +## Version 0.2.1 + +Hotfix release + +### Changes + + +- Fix: Properly load config + + + + ## Version 0.2 diff --git a/matemat/__init__.py b/matemat/__init__.py index c1ae7f9..34395d3 100644 --- a/matemat/__init__.py +++ b/matemat/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.2' +__version__ = '0.2.1' diff --git a/matemat/__main__.py b/matemat/__main__.py index 22043dd..a5cbe0b 100644 --- a/matemat/__main__.py +++ b/matemat/__main__.py @@ -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'])) diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index fc7af45..72723b0 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -2,7 +2,7 @@ # Maintainer: s3lph pkgname=matemat -pkgver=0.2 +pkgver=0.2.1 pkgrel=1 arch=('any') diff --git a/package/debian/matemat/DEBIAN/control b/package/debian/matemat/DEBIAN/control index 0b99949..da86517 100644 --- a/package/debian/matemat/DEBIAN/control +++ b/package/debian/matemat/DEBIAN/control @@ -1,5 +1,5 @@ Package: matemat -Version: 0.2 +Version: 0.2.1 Maintainer: s3lph Section: web Priority: optional