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