better error message when cfg file does not exist
This commit is contained in:
parent
5640c4ea08
commit
ac9e35123c
10
frappyman.py
10
frappyman.py
@ -23,7 +23,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from glob import glob
|
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 configparser import ConfigParser
|
||||||
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
||||||
|
|
||||||
@ -51,7 +51,13 @@ class FrappyManager(ServiceManager):
|
|||||||
cfgparser.optionxform = str
|
cfgparser.optionxform = str
|
||||||
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', service)
|
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', service)
|
||||||
cfgparser.read(cfgfile)
|
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('<SERV>'):
|
if cfgpath.endswith('<SERV>'):
|
||||||
cfgpaths.append(cfgpath[:-6] + service)
|
cfgpaths.append(cfgpath[:-6] + service)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user