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