explicitly define SERV path item in SECOP_CONFDIR
when an item in SECOP_CONFDIR ends with SERV, only the directory for the service is lookup up and not its parent
This commit is contained in:
parent
404288abbf
commit
97af531a5c
34
frappyman.py
34
frappyman.py
@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from os.path import join
|
from glob import glob
|
||||||
|
from os.path import join, isdir, basename
|
||||||
|
from configparser import ConfigParser
|
||||||
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
||||||
|
|
||||||
|
|
||||||
@ -36,6 +38,7 @@ class FrappyManager(ServiceManager):
|
|||||||
frappy start <instance> <service> <cfgfiles>
|
frappy start <instance> <service> <cfgfiles>
|
||||||
frappy restart <instance> [<service>] [<cfgfiles>]
|
frappy restart <instance> [<service>] [<cfgfiles>]
|
||||||
frappy stop <instance> [<service>]
|
frappy stop <instance> [<service>]
|
||||||
|
frappy listcfg <instance> [<service>] # list available cfg files
|
||||||
|
|
||||||
<service> is one of main, stick, addons
|
<service> is one of main, stick, addons
|
||||||
%s
|
%s
|
||||||
@ -44,7 +47,13 @@ class FrappyManager(ServiceManager):
|
|||||||
def config_dirs(self, ins, service):
|
def config_dirs(self, ins, service):
|
||||||
cfgpaths = []
|
cfgpaths = []
|
||||||
for cfgpath in self.env[ins].get('SECOP_CONFDIR', '').split(os.pathsep):
|
for cfgpath in self.env[ins].get('SECOP_CONFDIR', '').split(os.pathsep):
|
||||||
cfgpaths.extend([join(cfgpath, service), cfgpath])
|
if cfgpath.endswith('SERV'):
|
||||||
|
cfgpaths.append(cfgpath[:-4] + service)
|
||||||
|
else:
|
||||||
|
scfg = join(cfgpath, service)
|
||||||
|
if isdir(scfg):
|
||||||
|
cfgpaths.append(scfg)
|
||||||
|
cfgpaths.append(cfgpath)
|
||||||
return cfgpaths
|
return cfgpaths
|
||||||
|
|
||||||
def prepare_start(self, ins, service):
|
def prepare_start(self, ins, service):
|
||||||
@ -85,3 +94,24 @@ class FrappyManager(ServiceManager):
|
|||||||
win.show()
|
win.show()
|
||||||
|
|
||||||
return app.exec_()
|
return app.exec_()
|
||||||
|
|
||||||
|
def do_listcfg(self, ins='', service='main'):
|
||||||
|
for cfgdir in self.config_dirs(ins, service):
|
||||||
|
table = []
|
||||||
|
for cfgfile in glob(join(cfgdir, '*.cfg')):
|
||||||
|
desc = ''
|
||||||
|
try:
|
||||||
|
parser = ConfigParser()
|
||||||
|
parser.read(cfgfile)
|
||||||
|
for s in parser.sections():
|
||||||
|
if s == 'NODE' or s.startswith('node '):
|
||||||
|
desc = parser[s].get('description', '').split('\n')[0]
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
table.append((basename(cfgfile)[:-4], desc))
|
||||||
|
if table:
|
||||||
|
print('\n--- %s:\n' % cfgdir)
|
||||||
|
lcol = max(len(c) for c, _ in table)
|
||||||
|
for cfg, desc in table:
|
||||||
|
print('%s %s' % (cfg.ljust(lcol), desc))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user