make 'frappy listcfg' bhave like nicos 'frappy_list()'
This commit is contained in:
parent
0904390dc3
commit
e67fa0bc35
25
frappyman.py
25
frappyman.py
@ -49,15 +49,17 @@ class FrappyManager(ServiceManager):
|
||||
cfgpaths = []
|
||||
cfgparser = ConfigParser()
|
||||
cfgparser.optionxform = str
|
||||
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', service)
|
||||
cfgparser.read(cfgfile)
|
||||
try:
|
||||
section = cfgparser['FRAPPY']
|
||||
except KeyError:
|
||||
if exists(cfgfile):
|
||||
raise KeyError('%s has no FRAPPY section' % cfgfile) from None
|
||||
raise FileNotFoundError('%s not found' % cfgfile) from None
|
||||
for cfgpath in section['confdir'].split(os.pathsep):
|
||||
cfgfile = self.env[ins].get('FRAPPY_CONFIG_FILE')
|
||||
confdir = self.env[ins]['FRAPPY_CONFDIR']
|
||||
if cfgfile is not None:
|
||||
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].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)
|
||||
for cfgpath in confdir.split(os.pathsep):
|
||||
if cfgpath.endswith('<SERV>'):
|
||||
cfgpaths.append(cfgpath[:-6] + service)
|
||||
else:
|
||||
@ -146,17 +148,14 @@ class FrappyManager(ServiceManager):
|
||||
return result if by_dir else all_cfg
|
||||
|
||||
def do_listcfg(self, ins='', service=''):
|
||||
omit = 'develop'
|
||||
if service:
|
||||
all_cfg = self.all_cfg(ins, service, by_dir=True)
|
||||
if service == 'develop':
|
||||
omit = 'NONE'
|
||||
else:
|
||||
all_cfg = {}
|
||||
for service in self.services:
|
||||
all_cfg.update(self.all_cfg(ins, service, by_dir=True))
|
||||
for cfgdir, cfgs in all_cfg.items():
|
||||
if cfgs and not cfgdir.endswith(omit):
|
||||
if cfgs:
|
||||
print('\n--- %s:\n' % cfgdir)
|
||||
keylen = max(len(k) for k in cfgs)
|
||||
for cfg, desc in cfgs.items():
|
||||
|
Loading…
x
Reference in New Issue
Block a user