netsetup
Самоукин Алексей 14 years ago
parent 4ab9852aba
commit b04d6ecf51

@ -57,24 +57,22 @@ class DataVarsObject(DataVars):
class updateConfFiles(color_print):
"""Для обновления конфигурационных файлов"""
patternSect = re.compile("^\s*\[([^\[\]]+)\]\s*")
firstEnvFile = "/etc/calculate/calculate2.env"
def __init__(self):
clVars = DataVarsObject("install")
clVars.importDataObject()
self.clVars = clVars
self.installProgs = self.clVars.GetList("cl_merges")
def applyCltTemplate(self, cltTemplatePath):
"""Применяем clt шаблон"""
realPath = "/usr/lib/calculate-2.2/calculate-install"
pymPath = os.path.join(realPath,"pym")
if not os.path.isdir(pymPath) or\
not len(filter(lambda x:x.startswith("cl_vars_") and\
x.endswith(".py") or x.startswith("cl_fill_") and\
x.endswith(".py"), os.listdir(pymPath)))==2:
self.printERROR(_("Can not installed package %s")
if not "calculate-install" in self.installProgs:
self.printERROR(_("Can not installed %s")
%"calculate-install")
self.printWARNING(\
_("To install the program, run 'cl-install --install'"))
return False
dirsTemplates = self.clVars.Get("cl_template_clt_path")
flagFoundPath = False
@ -101,6 +99,8 @@ subdirectories %s")%', '.join(dirsTemplates))
%cltTemplatePath)
return False
calcPkg = self.clVars.Get("cl_name")+"-" + self.clVars.Get("cl_ver")
# merge
self.clVars.Set("cl_action", "merge", True)
nameFile = clTempl.applyTemplate(cltTemplatePath)
if nameFile is False:
self.printERROR(_("Error template in a package %s")\
@ -121,21 +121,14 @@ subdirectories %s")%', '.join(dirsTemplates))
def applyAllTemplates(self):
"""Обновление конфигурационных файлов"""
if not os.path.exists(self.firstEnvFile):
self.printERROR(_("File '%s' does not exist")%self.firstEnvFile)
return False
if not os.access(self.firstEnvFile, os.R_OK):
self.printERROR(_("Permission denied: '%s'")%self.firstEnvFile)
if not "calculate-install" in self.installProgs:
self.printERROR(_("Can not installed %s")
%"calculate-install")
self.printWARNING(\
_("To install the program, run 'cl-install --install'"))
return False
sectionsWork = []
for line in open(self.firstEnvFile).readlines():
sRet = self.patternSect.search(line)
if sRet:
sectionsWork.append(sRet.group(1))
installSect = "install"
if not installSect in sectionsWork:
sectionsWork.insert(0, installSect)
installSect = "install"
sectionsWork = map(lambda x: x.rpartition("-")[2], self.installProgs)
dictPakkages = {}
oldPymPath = ""
for sectName in sectionsWork:
@ -152,6 +145,8 @@ subdirectories %s")%', '.join(dirsTemplates))
oldPymPath = os.path.abspath(pymPath)
clVars = DataVarsObject(sectName)
clVars.importDataObject()
# merge
clVars.Set("cl_action", "merge", True)
# будут применены все шаблоны .clt (cltFilter=False)
# и обычные шаблоны
clTempl = template(clVars, cltFilter=False)

Loading…
Cancel
Save