|
|
|
@ -2229,12 +2229,12 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
# Регулярное выражение для умножениея и деления
|
|
|
|
|
sMD = re.compile("[^\-\+\*\/]+")
|
|
|
|
|
|
|
|
|
|
# стек глобальных переменных
|
|
|
|
|
stackGlobalVars = []
|
|
|
|
|
|
|
|
|
|
# директория установленных программ
|
|
|
|
|
basePkgDir = "/var/db/pkg"
|
|
|
|
|
|
|
|
|
|
# стек глобальных переменных
|
|
|
|
|
stackGlobalVars = []
|
|
|
|
|
|
|
|
|
|
# регулярное выражение для поиска версии
|
|
|
|
|
reFindVer = re.compile("(?<=\-)\d+\.?\d*\.?\d*")
|
|
|
|
|
|
|
|
|
@ -2264,8 +2264,14 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
self.namesTemplateFunction.append(nameFunction)
|
|
|
|
|
# Объект хранения переменных
|
|
|
|
|
self.objVar = objVar
|
|
|
|
|
# Базовая директория переноса шаблонов "/mnt/calculate" или "/" и.т.д
|
|
|
|
|
self._baseDir = self.objVar.Get("cl_root_path")
|
|
|
|
|
# Директория другой системы
|
|
|
|
|
self._chrootDir = self.objVar.Get("cl_chroot_path")
|
|
|
|
|
if self._chrootDir != '/':
|
|
|
|
|
# Изменение директории к базе пакетов
|
|
|
|
|
self.basePkgDir = os.path.join(self._chrootDir, self.basePkgDir[1:])
|
|
|
|
|
# Базовая директория переноса шаблонов "/mnt/calculate" или "/" и.т.д
|
|
|
|
|
self._baseDir = os.path.join(self._chrootDir,
|
|
|
|
|
self.objVar.Get("cl_root_path")[1:])
|
|
|
|
|
self._reFunc = re.compile(("%s%s%s")\
|
|
|
|
|
%(self.varStart,self._reFunctionText,self.varEnd),re.M)
|
|
|
|
|
# Аттрибуты для функции шаблона ini()
|
|
|
|
@ -2404,8 +2410,11 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
fileName = os.path.join(self.homeDir,
|
|
|
|
|
fileName.partition("/")[2],"")[:-1]
|
|
|
|
|
elif fileName[0] != "/":
|
|
|
|
|
path = os.path.split(nameSystemFile)[0]
|
|
|
|
|
fileName=os.path.join(path,fileName)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("wrong path '%s'")%fileName)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
fileName = os.path.join(self._baseDir,fileName[1:])
|
|
|
|
|
replace = ""
|
|
|
|
|
if os.path.exists(fileName):
|
|
|
|
|
replace = "1"
|
|
|
|
@ -2439,8 +2448,11 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
fileName = os.path.join(self.homeDir,
|
|
|
|
|
fileName.partition("/")[2],"")[:-1]
|
|
|
|
|
elif fileName[0] != "/":
|
|
|
|
|
path = os.path.split(nameSystemFile)[0]
|
|
|
|
|
fileName=os.path.join(path,fileName)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("wrong path '%s'")%fileName)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
fileName = os.path.join(self._baseDir,fileName[1:])
|
|
|
|
|
else:
|
|
|
|
|
fileName = terms[1].strip()
|
|
|
|
|
# Если домашняя директория
|
|
|
|
@ -2449,8 +2461,11 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
fileName = os.path.join(self.homeDir,
|
|
|
|
|
fileName.partition("/")[2],"")[:-1]
|
|
|
|
|
elif fileName[1] != "/":
|
|
|
|
|
path = os.path.split(nameSystemFile)[0]
|
|
|
|
|
fileName=os.path.join(path,fileName)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("wrong path '%s'")%fileName)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
fileName = os.path.join(self._baseDir,fileName[1:])
|
|
|
|
|
replace = ""
|
|
|
|
|
if os.path.exists(fileName):
|
|
|
|
|
FD = open(fileName)
|
|
|
|
@ -3091,7 +3106,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
cl_overriding.printERROR(_("error template term '%s'")\
|
|
|
|
|
%str(self.functText))
|
|
|
|
|
|
|
|
|
|
def applyFuncTemplate(self, textTemplate, nameTemplate, nameSystemFile):
|
|
|
|
|
def applyFuncTemplate(self, textTemplate, nameTemplate):
|
|
|
|
|
"""Применяет функции к тексту шаблона"""
|
|
|
|
|
# Локальные переменные
|
|
|
|
|
localVars = {}
|
|
|
|
@ -3209,7 +3224,8 @@ re.M|re.S)
|
|
|
|
|
# Объект с переменными
|
|
|
|
|
self.objVar = objVar
|
|
|
|
|
# Базовая директория переноса шаблонов "/mnt/calculate" или "/" и.т.д
|
|
|
|
|
self._baseDir = self.objVar.Get("cl_root_path")
|
|
|
|
|
self._baseDir = os.path.join(self.objVar.Get("cl_chroot_path"),
|
|
|
|
|
self.objVar.Get("cl_root_path")[1:])
|
|
|
|
|
# Последняя часть директории шаблона (имя сервиса: samba, mail)
|
|
|
|
|
self._servDir = servDir
|
|
|
|
|
if self._servDir:
|
|
|
|
@ -3339,43 +3355,31 @@ re.M|re.S)
|
|
|
|
|
resS = self._reVar.search(textTemplateTmp)
|
|
|
|
|
return textTemplateTmp
|
|
|
|
|
|
|
|
|
|
def applyTermsTemplate(self,textTemplate,nameTemplate,nameSystemFile=False):
|
|
|
|
|
def applyTermsTemplate(self,textTemplate,nameTemplate):
|
|
|
|
|
""" Применяет условия, к условным блокам текста
|
|
|
|
|
"""
|
|
|
|
|
def function(text):
|
|
|
|
|
"""Функция обработки функций в заголовке"""
|
|
|
|
|
return self.applyFuncTemplate(text, nameTemplate)
|
|
|
|
|
|
|
|
|
|
textTerm = ""
|
|
|
|
|
resS = self._reTermBloc.search(textTemplate)
|
|
|
|
|
textTemplateTmp = textTemplate
|
|
|
|
|
def function(text):
|
|
|
|
|
"""Функция обработки функций в заголовке"""
|
|
|
|
|
return self.applyFuncTemplate(text, nameTemplate, nameSystemFile)
|
|
|
|
|
if nameSystemFile:
|
|
|
|
|
while resS:
|
|
|
|
|
mark = resS.group(0)
|
|
|
|
|
body = resS.group("body")
|
|
|
|
|
end = resS.group("end")
|
|
|
|
|
parent = resS.group("func")
|
|
|
|
|
if not parent:
|
|
|
|
|
parent = ""
|
|
|
|
|
term = resS.group("rTerm") + parent +\
|
|
|
|
|
resS.group("lTerm")
|
|
|
|
|
if self._equalTerm(term, _("content template not valid: ")+\
|
|
|
|
|
nameTemplate, function):
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, body+end)
|
|
|
|
|
else:
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, "")
|
|
|
|
|
resS = self._reTermBloc.search(textTemplateTmp)
|
|
|
|
|
else:
|
|
|
|
|
while resS:
|
|
|
|
|
mark = resS.group(0)
|
|
|
|
|
body = resS.group("body")
|
|
|
|
|
end = resS.group("end")
|
|
|
|
|
term = resS.group("rTerm") + resS.group("lTerm")
|
|
|
|
|
if self._equalTerm(term, _("content template not valid: ")+\
|
|
|
|
|
nameTemplate):
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, body+end)
|
|
|
|
|
else:
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, "")
|
|
|
|
|
resS = self._reTermBloc.search(textTemplateTmp)
|
|
|
|
|
while resS:
|
|
|
|
|
mark = resS.group(0)
|
|
|
|
|
body = resS.group("body")
|
|
|
|
|
end = resS.group("end")
|
|
|
|
|
parent = resS.group("func")
|
|
|
|
|
if not parent:
|
|
|
|
|
parent = ""
|
|
|
|
|
term = resS.group("rTerm") + parent +\
|
|
|
|
|
resS.group("lTerm")
|
|
|
|
|
if self._equalTerm(term, _("content template not valid: ")+\
|
|
|
|
|
nameTemplate, function):
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, body+end)
|
|
|
|
|
else:
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, "")
|
|
|
|
|
resS = self._reTermBloc.search(textTemplateTmp)
|
|
|
|
|
return textTemplateTmp
|
|
|
|
|
|
|
|
|
|
def getNeedTemplate(self, fileTemplate):
|
|
|
|
@ -3641,7 +3645,7 @@ re.M|re.S)
|
|
|
|
|
|
|
|
|
|
def function(text):
|
|
|
|
|
"""Функция обработки функций в заголовке"""
|
|
|
|
|
return self.applyFuncTemplate(text, templateDirFile, newDir)
|
|
|
|
|
return self.applyFuncTemplate(text, templateDirFile)
|
|
|
|
|
|
|
|
|
|
def chownConfDir(nameDirConfig, uid, gid, nameFileTemplate):
|
|
|
|
|
"""Изменение владельца конфигурационной директории"""
|
|
|
|
@ -3699,8 +3703,7 @@ re.M|re.S)
|
|
|
|
|
textTemplate = self.applyVarsTemplate(textTemplate, templateDirFile)
|
|
|
|
|
|
|
|
|
|
# Заменяем функции на их значения
|
|
|
|
|
textTemplate = self.applyFuncTemplate(textTemplate, templateDirFile,
|
|
|
|
|
applyDir)
|
|
|
|
|
textTemplate = self.applyFuncTemplate(textTemplate, templateDirFile)
|
|
|
|
|
# Обработка заголовка
|
|
|
|
|
objHead = dirHeader(templateDirFile,textTemplate,self.objVar,function)
|
|
|
|
|
# Директория с профилями не будет применена
|
|
|
|
@ -3840,7 +3843,7 @@ re.M|re.S)
|
|
|
|
|
|
|
|
|
|
def function(text):
|
|
|
|
|
"""Функция обработки функций в заголовке"""
|
|
|
|
|
return self.applyFuncTemplate(text,nameFileTemplate,nameFileConfig)
|
|
|
|
|
return self.applyFuncTemplate(text,nameFileTemplate)
|
|
|
|
|
|
|
|
|
|
def renameConfFileCLT(nameFileConfig):
|
|
|
|
|
"""Изменение название файла templ.conf.clt на templ.conf"""
|
|
|
|
@ -4234,15 +4237,13 @@ re.M|re.S)
|
|
|
|
|
if templateFileType != "bin":
|
|
|
|
|
# Вычисляем условные блоки
|
|
|
|
|
self.textTemplate = self.applyTermsTemplate(self.textTemplate,
|
|
|
|
|
nameFileTemplate,
|
|
|
|
|
nameFileConfig)
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
# Заменяем переменные на их значения
|
|
|
|
|
self.textTemplate = self.applyVarsTemplate(self.textTemplate,
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
# Вычисляем функции
|
|
|
|
|
self.textTemplate = self.applyFuncTemplate(self.textTemplate,
|
|
|
|
|
nameFileTemplate,
|
|
|
|
|
nameFileConfig)
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
flagCopyTemplate = False
|
|
|
|
|
filesApply, objHeadNew = self.__getApplyHeadTemplate(nameFileTemplate,
|
|
|
|
|
nameFileConfig,
|
|
|
|
|