X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flaunch.py;h=733d237e2f12b3f0714c9c2ae2214aac6b977963;hb=325e87e6aaf33974ea8bc8e4b3d2fdbbef56e9a9;hp=24802bf043701648a3635a88db79eec2eda0e9b4;hpb=cae35b4090eaeb8eec24c7ea77ec2311f3fc0608;p=mpd-sima.git diff --git a/sima/launch.py b/sima/launch.py index 24802bf..733d237 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -1,4 +1,22 @@ # -*- coding: utf-8 -*- +# Copyright (c) 2013, 2014 Jack Kaliko +# +# This file is part of sima +# +# sima is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# sima is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with sima. If not, see . +# +# """Sima """ @@ -31,7 +49,7 @@ def load_plugins(sima, source): sima: sima.core.Sima instance source: ['internal', 'contrib'] """ - if not sima.config.get('sima', source ): + if not sima.config.get('sima', source): return logger = logging.getLogger('sima') for plugin in sima.config.get('sima', source).split(','): @@ -40,7 +58,8 @@ def load_plugins(sima, source): try: mod_obj = __import__(module, fromlist=[plugin]) except ImportError as err: - logger.error('Failed to load plugin\'s module: {0} ({1})'.format(module, err)) + logger.error('Failed to load plugin\'s module: ' + + '{0} ({1})'.format(module, err)) sima.shutdown() sys.exit(1) try: @@ -49,7 +68,8 @@ def load_plugins(sima, source): logger.error('Failed to load plugin {0} ({1})'.format(plugin, err)) sima.shutdown() sys.exit(1) - logger.info('Loading {0} plugin: {name} ({doc})'.format(source, **plugin_obj.info())) + logger.info('Loading {0} plugin: {name} ({doc})'.format( + source, **plugin_obj.info())) sima.register_plugin(plugin_obj) @@ -59,15 +79,13 @@ def start(sopt, restart=False): # set logger verbosity = sopt.options.get('verbosity', 'warning') logfile = sopt.options.get('logfile', None) - cli_loglevel = getattr(logging, verbosity.upper()) - set_logger(level=verbosity, logfile=logfile) - logger = logging.getLogger('sima') - logger.setLevel(cli_loglevel) + set_logger(verbosity, logfile) # loads configuration - config = ConfMan(logger, sopt.options).config - logger.setLevel(getattr(logging, - config.get('log', 'verbosity').upper())) # pylint: disable=E1103 - + config = ConfMan(sopt.options).config + logfile = config.get('log', 'logfile') + verbosity = config.get('log', 'verbosity') + set_logger(verbosity, logfile) + logger = logging.getLogger('sima') logger.debug('Command line say: {0}'.format(sopt.options)) # Create Database db_file = config.get('sima', 'db_file') @@ -115,13 +133,14 @@ def run(sopt, restart=False): # pylint: disable=broad-except try: start(sopt, restart) - except SigHup as err: # SigHup inherit from Exception + except SigHup: # SigHup inherit from Exception run(sopt, True) except Exception: # Unhandled exception exception_log() # Script starts here def main(): + """Entry point""" nfo = dict({'version': info.__version__, 'prog': 'sima'}) # StartOpt gathers options from command line call (in StartOpt().options)