diff --git a/frappyman.py b/frappyman.py index 948b938..edbeab6 100644 --- a/frappyman.py +++ b/frappyman.py @@ -23,7 +23,7 @@ import sys import os from glob import glob -from os.path import join, isdir, basename, expanduser +from os.path import join, isdir, basename, expanduser, exists from configparser import ConfigParser from servicemanager.base import ServiceManager, ServiceDown, UsageError @@ -51,7 +51,13 @@ class FrappyManager(ServiceManager): cfgparser.optionxform = str cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('', service) cfgparser.read(cfgfile) - for cfgpath in cfgparser['FRAPPY']['confdir'].split(os.pathsep): + try: + section = cfgparser['FRAPPY'] + except KeyError: + if exists(cfgfile): + raise KeyError('%s has no FRAPPY section' % cfgfile) + raise FileNotFoundError('%s does not exist' % cfgfile) + for cfgpath in section['confdir'].split(os.pathsep): if cfgpath.endswith(''): cfgpaths.append(cfgpath[:-6] + service) else: