From b04d6ecf511f704ea7d9a65aafe2f8f7aa9fddf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 11 Aug 2010 12:59:09 +0000 Subject: [PATCH] Bigfix --- pym/cl_apply_template.py | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/pym/cl_apply_template.py b/pym/cl_apply_template.py index b9bb896..1377e50 100644 --- a/pym/cl_apply_template.py +++ b/pym/cl_apply_template.py @@ -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)