fix errors in frappyman
+ missing section key FRAPPY + use expanduser
This commit is contained in:
parent
192bdca648
commit
1f5bdcde8d
20
frappyman.py
20
frappyman.py
@ -23,7 +23,7 @@
|
||||
import sys
|
||||
import os
|
||||
from glob import glob
|
||||
from os.path import join, isdir, basename
|
||||
from os.path import join, isdir, basename, expanduser
|
||||
from configparser import ConfigParser
|
||||
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
||||
|
||||
@ -49,22 +49,24 @@ class FrappyManager(ServiceManager):
|
||||
cfgpaths = []
|
||||
cfgparser = ConfigParser()
|
||||
cfgparser.optionxform = str
|
||||
cfgparser.read(self.env[ins]['FRAPPY_CONFIG_FILE'])
|
||||
for cfgpath in cfgparser['confdir'].split(os.pathsep):
|
||||
if cfgpath.endswith('SERV'):
|
||||
cfgpaths.append(cfgpath[:-4] + service)
|
||||
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', service)
|
||||
cfgparser.read(cfgfile)
|
||||
for cfgpath in cfgparser['FRAPPY']['confdir'].split(os.pathsep):
|
||||
if cfgpath.endswith('<SERV>'):
|
||||
cfgpaths.append(cfgpath[:-6] + service)
|
||||
else:
|
||||
scfg = join(cfgpath, service)
|
||||
if isdir(scfg):
|
||||
cfgpaths.append(scfg)
|
||||
cfgpaths.append(cfgpath)
|
||||
cfgpaths.append(expanduser(cfgpath))
|
||||
return cfgpaths
|
||||
|
||||
def prepare_start(self, ins, service, cfg=''):
|
||||
start_dir, env = super().prepare_start(ins, service)
|
||||
his = env.get('FRAPPY_HISTORY')
|
||||
if his:
|
||||
env['FRAPPY_HISTORY'] = his.replace('_SERVICE', '_' + service)
|
||||
for key, value in env.items():
|
||||
if '<SERV>' in value:
|
||||
env[key] = value.replace('<SERV>', service)
|
||||
os.environ[key] = env[key]
|
||||
cfgpaths = self.config_dirs(ins, service)
|
||||
if cfgpaths:
|
||||
env['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths)
|
||||
|
Loading…
x
Reference in New Issue
Block a user