avoid KeyError when frappy is used with an invalid instrument
This commit is contained in:
2
base.py
2
base.py
@ -155,9 +155,9 @@ class ServiceManager:
|
||||
if cmd.startswith('PY '):
|
||||
cmd = env.get('PY', 'python3') + cmd[2:]
|
||||
self.commands[ins] = cmd
|
||||
self.info = result
|
||||
if len(self.info) == 1:
|
||||
self.single_ins = list(self.info)[0]
|
||||
self.info = result
|
||||
|
||||
#def get_cmdpats(self, groups):
|
||||
# return self.cmdpats
|
||||
|
@ -114,16 +114,19 @@ class FrappyManager(ServiceManager):
|
||||
cfgpaths = []
|
||||
cfgparser = ConfigParser()
|
||||
cfgparser.optionxform = str
|
||||
cfgfile = self.env[ins].get('FRAPPY_CONFIG_FILE')
|
||||
confdir = self.env[ins].get('FRAPPY_CONFDIR')
|
||||
env = self.env.get(ins, {})
|
||||
cfgfile = env.get('FRAPPY_CONFIG_FILE')
|
||||
confdir = env.get('FRAPPY_CONFDIR')
|
||||
if cfgfile:
|
||||
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', service)
|
||||
cfgfile = cfgfile.replace('<SERV>', service)
|
||||
cfgparser.read(cfgfile)
|
||||
try:
|
||||
section = cfgparser['FRAPPY']
|
||||
except KeyError:
|
||||
raise ValueError('%s does not exist or has no FRAPPY section' % cfgfile)
|
||||
confdir = section.get('confdir', confdir)
|
||||
if not confdir:
|
||||
return []
|
||||
for cfgpath in confdir.split(os.pathsep):
|
||||
if cfgpath.endswith('<SERV>'):
|
||||
cfgpaths.append(expanduser(cfgpath[:-6] + service))
|
||||
|
Reference in New Issue
Block a user