fix errors in frappyman

+ missing section key FRAPPY
+ use expanduser
This commit is contained in:
zolliker 2022-04-26 09:49:45 +02:00
parent 192bdca648
commit 1f5bdcde8d

View File

@ -23,7 +23,7 @@
import sys import sys
import os import os
from glob import glob from glob import glob
from os.path import join, isdir, basename from os.path import join, isdir, basename, expanduser
from configparser import ConfigParser from configparser import ConfigParser
from servicemanager.base import ServiceManager, ServiceDown, UsageError from servicemanager.base import ServiceManager, ServiceDown, UsageError
@ -49,22 +49,24 @@ class FrappyManager(ServiceManager):
cfgpaths = [] cfgpaths = []
cfgparser = ConfigParser() cfgparser = ConfigParser()
cfgparser.optionxform = str cfgparser.optionxform = str
cfgparser.read(self.env[ins]['FRAPPY_CONFIG_FILE']) cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', service)
for cfgpath in cfgparser['confdir'].split(os.pathsep): cfgparser.read(cfgfile)
if cfgpath.endswith('SERV'): for cfgpath in cfgparser['FRAPPY']['confdir'].split(os.pathsep):
cfgpaths.append(cfgpath[:-4] + service) if cfgpath.endswith('<SERV>'):
cfgpaths.append(cfgpath[:-6] + service)
else: else:
scfg = join(cfgpath, service) scfg = join(cfgpath, service)
if isdir(scfg): if isdir(scfg):
cfgpaths.append(scfg) cfgpaths.append(scfg)
cfgpaths.append(cfgpath) cfgpaths.append(expanduser(cfgpath))
return cfgpaths return cfgpaths
def prepare_start(self, ins, service, cfg=''): def prepare_start(self, ins, service, cfg=''):
start_dir, env = super().prepare_start(ins, service) start_dir, env = super().prepare_start(ins, service)
his = env.get('FRAPPY_HISTORY') for key, value in env.items():
if his: if '<SERV>' in value:
env['FRAPPY_HISTORY'] = his.replace('_SERVICE', '_' + service) env[key] = value.replace('<SERV>', service)
os.environ[key] = env[key]
cfgpaths = self.config_dirs(ins, service) cfgpaths = self.config_dirs(ins, service)
if cfgpaths: if cfgpaths:
env['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths) env['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths)