From e69c2dcbbfa72d1b9ab10d2f89b4dce5eb0d3e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 15 Nov 2015 13:39:22 +0100 Subject: Change configuration check to use if instead exceptions --- mcwrapper | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'mcwrapper') diff --git a/mcwrapper b/mcwrapper index 2784305..4c897d3 100755 --- a/mcwrapper +++ b/mcwrapper @@ -45,17 +45,9 @@ else: # else load configuration __set_empty_config__() # Set additional runtime configuration variables -try: - conf.verbose_level -except AttributeError: +if not 'verbose_level' in vars(conf): conf.verbose_level = 0 -try: - conf.command -except AttributeError: - conf.command = [] -try: - conf.server -except AttributeError: +if not 'server' in vars(conf): conf.server = dict() ################################################################################# @@ -263,22 +255,13 @@ if __name__ == '__main__': conf.server[conf.identifier] vars(conf).update(conf.server[conf.identifier]) except KeyError: - if conf.verbose_level >= -1: - sys.exit('Error: No configuration associated with identifier: ' + conf.identifier) - else: - sys.exit(); - # Set configurations for server - try: - conf.directory - except AttributeError: + sys.exit('Error: No configuration associated with identifier: ' + conf.identifier) + # Check configurations for server + if not 'directory' in vars(conf): sys.exit('Missing "directory" config for server ' + conf.identifier) - try: - conf.command - except AttributeError: + if not 'command' in vars(conf): sys.exit('Missing server start command for server ' + conf.identifier) - try: - conf.status - except AttributeError: + if not 'status' in vars(conf): conf.status = '/dev/shm/mcwrapper-' + conf.identifier # Set inputPipe global inputPipe -- cgit v1.2.3