|
|
|
@ -332,7 +332,7 @@ class _terms(_error, _shareTermsFunction):
|
|
|
|
|
self.setError("'%s'"%rpl(term)+" "+\
|
|
|
|
|
_("incorrect"))
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Value function is not version"))
|
|
|
|
|
_("Function value is not version"))
|
|
|
|
|
return False
|
|
|
|
|
verFile, verVar = self._convertVers(vals[1],valVars)
|
|
|
|
|
res = dictRuleFunc[sepF](verVar,verFile)
|
|
|
|
@ -567,7 +567,7 @@ class fileHeader(_terms):
|
|
|
|
|
foundTerm = True
|
|
|
|
|
errorMsg = _("Incorrect template") +\
|
|
|
|
|
": "+ templateName +"\n"+\
|
|
|
|
|
_("header template not valid")+\
|
|
|
|
|
_("template header not valid")+\
|
|
|
|
|
": "+ i
|
|
|
|
|
if function:
|
|
|
|
|
rezTerm = self._equalTerm(i,
|
|
|
|
@ -714,7 +714,7 @@ class dirHeader(_terms):
|
|
|
|
|
foundTerm = True
|
|
|
|
|
errorMsg = _("Incorrect template") +\
|
|
|
|
|
": "+ templateName +"\n"+\
|
|
|
|
|
_("header template not valid")+ ": "+ i
|
|
|
|
|
_("template header not valid")+ ": "+ i
|
|
|
|
|
if function:
|
|
|
|
|
rezTerm = self._equalTerm(i, errorMsg,
|
|
|
|
|
function)
|
|
|
|
@ -2103,7 +2103,8 @@ class _file(_error):
|
|
|
|
|
try:
|
|
|
|
|
self.F_CONF.write(self.textConfig)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("not open file:" ) + self.nameFileConfig)
|
|
|
|
|
self.setError(_("unable to open the file:" ) +
|
|
|
|
|
self.nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
self.F_CONF.flush()
|
|
|
|
|
return True
|
|
|
|
@ -2114,7 +2115,7 @@ class _file(_error):
|
|
|
|
|
try:
|
|
|
|
|
F_TEMPL = open(nameFileTemplate, "r")
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("not open file:" ) + nameFileTemplate)
|
|
|
|
|
self.setError(_("unable to open the file:" ) + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
return F_TEMPL
|
|
|
|
|
|
|
|
|
@ -2140,7 +2141,7 @@ class _file(_error):
|
|
|
|
|
try:
|
|
|
|
|
F_CONF = open(nameFileConfig, "w+")
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("not open file:" ) + nameFileConfig)
|
|
|
|
|
self.setError(_("unable to open the file:" ) + nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return F_CONF
|
|
|
|
|
|
|
|
|
@ -2396,7 +2397,7 @@ class _shareTemplate:
|
|
|
|
|
gid = pwdObj.pw_gid
|
|
|
|
|
homeDir = pwdObj.pw_dir
|
|
|
|
|
except:
|
|
|
|
|
cl_overriding.printERROR(_("Can not found user %s")%str(userName))
|
|
|
|
|
cl_overriding.printERROR(_("User %s not found")%str(userName))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if groupsInfo:
|
|
|
|
|
import grp
|
|
|
|
@ -2404,7 +2405,7 @@ class _shareTemplate:
|
|
|
|
|
groupName = grp.getgrgid(gid).gr_name
|
|
|
|
|
except:
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("Can not found group id %s")%str(gid))
|
|
|
|
|
_("Id of group %s not found")%str(gid))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
groupsNames = map(lambda x: x.gr_name,\
|
|
|
|
|
filter(lambda x: userName in x.gr_mem, grp.getgrall()))
|
|
|
|
@ -2547,7 +2548,8 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
except:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("error var %s not int")%str(strNum))
|
|
|
|
|
_("error, variable %s not a number")%
|
|
|
|
|
str(strNum))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
elif self.objVar.exists(strNum):
|
|
|
|
|
try:
|
|
|
|
@ -2555,19 +2557,21 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
except:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("error var %s not int")%str(strNum))
|
|
|
|
|
_("error, variable %s not a number")%
|
|
|
|
|
str(strNum))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("error local var %s not defined")%str(strNum))
|
|
|
|
|
_("error, local variable %s is not defined")%
|
|
|
|
|
str(strNum))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if minus:
|
|
|
|
|
num = -num
|
|
|
|
|
strNumers.append(num)
|
|
|
|
|
return sum(strNumers)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("error template term %s, incorrect data")\
|
|
|
|
|
cl_overriding.printERROR(_("error, template term %s, incorrect data")\
|
|
|
|
|
%str(term))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
|
@ -2634,7 +2638,7 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("Second argument function is not 'root'"))
|
|
|
|
|
_("The second argument of the function is not 'root'"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if fileName[0] == "~":
|
|
|
|
|
# Получаем директорию пользователя
|
|
|
|
@ -2679,14 +2683,14 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("Third argument function is not 'root'"))
|
|
|
|
|
_("The third argument of the function is not 'root'"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if lenTerms >= 2:
|
|
|
|
|
if not terms[0] in ["ver","num","char","key","empty"]:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("first argument function is not 'ver' or 'num' or 'char'"
|
|
|
|
|
" or 'empty'"))
|
|
|
|
|
_("the first argument of the function is not "
|
|
|
|
|
"'ver' or 'num' or 'char' or 'empty'"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
|
|
if lenTerms == 1:
|
|
|
|
@ -2811,14 +2815,15 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("first argument function must be 'num','pas' or 'uuid'"))
|
|
|
|
|
_("the first argument of the function "
|
|
|
|
|
"must be 'num','pas' or 'uuid'"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
try:
|
|
|
|
|
lenStr = int(terms[1])
|
|
|
|
|
except:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("two argument function is not number"))
|
|
|
|
|
_("the second argument of the function is not a number"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
choiceStr = fArgvNames[terms[0]]
|
|
|
|
|
replace = ''.join([random.choice(choiceStr) for i in xrange(lenStr)])
|
|
|
|
@ -2844,15 +2849,16 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
fArgvNames = ['upper','lower','capitalize']
|
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("first argument function is not 'upper' \
|
|
|
|
|
or 'lower' or 'capitalize'"))
|
|
|
|
|
cl_overriding.printERROR(_("the first argument of the function is "
|
|
|
|
|
"not 'upper' or 'lower' or 'capitalize'"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
try:
|
|
|
|
|
strValue = str(self.objVar.Get(terms[1]))
|
|
|
|
|
except:
|
|
|
|
|
cl_overriding.printERROR(_("error in template %s")\
|
|
|
|
|
%self.nameTemplate)
|
|
|
|
|
cl_overriding.printERROR(_("error var %s not found")%str(terms[1]))
|
|
|
|
|
cl_overriding.printERROR(_("error, variable %s not found")%
|
|
|
|
|
str(terms[1]))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
replace = ""
|
|
|
|
|
strValue = _toUNICODE(strValue)
|
|
|
|
@ -2892,14 +2898,14 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
self.stackGlobalVars.append(str(value))
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("error var %s exists")\
|
|
|
|
|
cl_overriding.printERROR(_("error, variable %s exists")\
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
# Если переменная не существует
|
|
|
|
|
if len(terms) == 1:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("error var %s not exists")\
|
|
|
|
|
cl_overriding.printERROR(_("error, variable %s does not exist")\
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
elif len(terms) == 2:
|
|
|
|
@ -2929,7 +2935,7 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("error, gloval variables stack is empty"))
|
|
|
|
|
_("error, global variables stack is empty"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
@ -3036,8 +3042,8 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
elif len(terms) == 3:
|
|
|
|
|
if not terms[2] in ['url','purl','unicode']:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(_("third argument function is not "
|
|
|
|
|
"'url' or 'purl' or 'unicode'"))
|
|
|
|
|
cl_overriding.printERROR(_("the third argument of the function"
|
|
|
|
|
" is not 'url' or 'purl' or 'unicode'"))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if terms[1]:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
@ -3276,13 +3282,13 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
pass
|
|
|
|
|
if not flagFoundVar:
|
|
|
|
|
# Если переменная не существует
|
|
|
|
|
cl_overriding.printERROR(_("error var %s not exists")\
|
|
|
|
|
cl_overriding.printERROR(_("error, variable %s does not exist")\
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if not type(value) in (list,tuple):
|
|
|
|
|
# Значение переменной не список или кортеж
|
|
|
|
|
cl_overriding.printERROR(_("value of %s is not a list or tuple")\
|
|
|
|
|
cl_overriding.printERROR(_("value of %s is not a list or a tuple")\
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
@ -3292,7 +3298,7 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
else:
|
|
|
|
|
replace = ""
|
|
|
|
|
except:
|
|
|
|
|
cl_overriding.printERROR(_("%s wrong")%strIndex)
|
|
|
|
|
cl_overriding.printERROR(_("wrong %s")%strIndex)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
|
@ -3317,7 +3323,7 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
mountPoint = terms[0]
|
|
|
|
|
lastElementVar = terms[1]
|
|
|
|
|
if not mountPoint or mountPoint[:1] !="/":
|
|
|
|
|
cl_overriding.printERROR(_("%s wrong")%lastElementVar)
|
|
|
|
|
cl_overriding.printERROR(_("wrong %s")%lastElementVar)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
nameVar = "os_install_disk_mount"
|
|
|
|
@ -3325,7 +3331,8 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
valueVar = self.objVar.Get(nameVar)
|
|
|
|
|
except:
|
|
|
|
|
# Если переменная не существует
|
|
|
|
|
cl_overriding.printERROR(_("error var %s not exists")%nameVar)
|
|
|
|
|
cl_overriding.printERROR(_("error, variable %s does not exist")%
|
|
|
|
|
nameVar)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
nameElementVar = "os_install_disk_%s"%lastElementVar
|
|
|
|
@ -3337,20 +3344,20 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
try:
|
|
|
|
|
valueElementVar = self.objVar.Get(nameElementVar)
|
|
|
|
|
except:
|
|
|
|
|
cl_overriding.printERROR(_("%s wrong")%lastElementVar)
|
|
|
|
|
cl_overriding.printERROR(_("error var %s not exists")\
|
|
|
|
|
cl_overriding.printERROR(_("wrong %s")%lastElementVar)
|
|
|
|
|
cl_overriding.printERROR(_("error, variable %s does not exist")\
|
|
|
|
|
%nameElementVar)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if not type(valueVar) in (list,tuple):
|
|
|
|
|
# Значение переменной не список или кортеж
|
|
|
|
|
cl_overriding.printERROR(_("value of %s is not a list or tuple")\
|
|
|
|
|
cl_overriding.printERROR(_("value of %s is not a list or a tuple")\
|
|
|
|
|
%nameVar)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
if not type(valueElementVar) in (list,tuple):
|
|
|
|
|
# Значение переменной не список или кортеж
|
|
|
|
|
cl_overriding.printERROR(_("value of %s is not a list or tuple")\
|
|
|
|
|
cl_overriding.printERROR(_("value of %s is not a list or a tuple")\
|
|
|
|
|
%nameElementVar)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
@ -3371,8 +3378,8 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
index = num
|
|
|
|
|
break
|
|
|
|
|
if index is None:
|
|
|
|
|
cl_overriding.printERROR(_("in the value of the variable \
|
|
|
|
|
os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
cl_overriding.printERROR(_("mount point '\\' or '\\%s' not found "
|
|
|
|
|
"in the value of variable os_disk_install")%mountPoint)
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
replace = valueElementVar[index]
|
|
|
|
@ -3421,7 +3428,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
def printErrTemplate(self):
|
|
|
|
|
"""Печать ошибки при обработке функций шаблона"""
|
|
|
|
|
cl_overriding.printERROR(_("error in template %s")%self.nameTemplate)
|
|
|
|
|
cl_overriding.printERROR(_("error template term '%s'")\
|
|
|
|
|
cl_overriding.printERROR(_("error, template term '%s'")\
|
|
|
|
|
%str(self.functText))
|
|
|
|
|
|
|
|
|
|
def applyFuncTemplate(self, textTemplate, nameTemplate):
|
|
|
|
@ -3452,7 +3459,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
else:
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
_("can not found template function '%s'")\
|
|
|
|
|
_("function of templates '%s' not found")\
|
|
|
|
|
%str(self.functText))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
|
@ -3539,7 +3546,7 @@ class template(_file,_terms,_warning,xmlShare,templateFormat,_shareTemplate):
|
|
|
|
|
self.__titleHead = "--------------------------------------\
|
|
|
|
|
----------------------------------------"
|
|
|
|
|
self._titleBody = ""
|
|
|
|
|
self._titleList = ("Modified", "Processed template files" + ":")
|
|
|
|
|
self._titleList = ("Modified", "Processing template files" + ":")
|
|
|
|
|
self._reVar = re.compile(("%s[a-zA-Z0-9_-]+%s")%(self.varStart,
|
|
|
|
|
self.varEnd),re.M)
|
|
|
|
|
# Условия
|
|
|
|
@ -3625,7 +3632,7 @@ re.M|re.S)
|
|
|
|
|
try:
|
|
|
|
|
res = string.atoi(strOct, 8)
|
|
|
|
|
except ValueError:
|
|
|
|
|
self.setError(_("Not valid oct value: ") + str(strOct))
|
|
|
|
|
self.setError(_("Invalid oct value: ") + str(strOct))
|
|
|
|
|
return False
|
|
|
|
|
return res
|
|
|
|
|
else:
|
|
|
|
@ -3664,7 +3671,7 @@ re.M|re.S)
|
|
|
|
|
try:
|
|
|
|
|
dUid,dGid = getModeFile(prevDir,"owner")
|
|
|
|
|
except OSError:
|
|
|
|
|
self.setError(_("Not access dir: " ) + prevDir)
|
|
|
|
|
self.setError(_("No access to the directory: " ) + prevDir)
|
|
|
|
|
return False
|
|
|
|
|
if not mode is False:
|
|
|
|
|
dMode = mode
|
|
|
|
@ -3682,7 +3689,8 @@ re.M|re.S)
|
|
|
|
|
os.mkdir(nameDir)
|
|
|
|
|
os.chown(nameDir, dUid, dGid)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Can not create dir: " ) + nameDir)
|
|
|
|
|
self.setError(_("Failed to create the directory: " ) +
|
|
|
|
|
nameDir)
|
|
|
|
|
return False
|
|
|
|
|
try:
|
|
|
|
|
if dMode:
|
|
|
|
@ -3693,7 +3701,7 @@ re.M|re.S)
|
|
|
|
|
os.chown(dirName, dUid, dGid)
|
|
|
|
|
createDirs.append(dirName)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Can not create dir: " ) + dirName)
|
|
|
|
|
self.setError(_("Failed to create the directory: " ) + dirName)
|
|
|
|
|
return False
|
|
|
|
|
return createDirs
|
|
|
|
|
|
|
|
|
@ -3735,7 +3743,7 @@ re.M|re.S)
|
|
|
|
|
parent = ""
|
|
|
|
|
term = resS.group("rTerm") + parent +\
|
|
|
|
|
resS.group("lTerm")
|
|
|
|
|
if self._equalTerm(term, _("content template not valid: ")+\
|
|
|
|
|
if self._equalTerm(term, _("invalid template content: ")+\
|
|
|
|
|
nameTemplate, function):
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, body+end)
|
|
|
|
|
else:
|
|
|
|
@ -3752,7 +3760,7 @@ re.M|re.S)
|
|
|
|
|
if len(spFile)>1:
|
|
|
|
|
flagTrue = False
|
|
|
|
|
for term in spFile[1:]:
|
|
|
|
|
if self._equalTerm(term, _("name template not valid: ")+\
|
|
|
|
|
if self._equalTerm(term, _("invalid template name: ")+\
|
|
|
|
|
fileTemplate):
|
|
|
|
|
flagTrue = True
|
|
|
|
|
break
|
|
|
|
@ -3763,7 +3771,7 @@ re.M|re.S)
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("name template not valid: ")+ str(fileTemplate))
|
|
|
|
|
self.setError(_("invalid template name: ")+ str(fileTemplate))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def getTitle(self, comment, commentList, configPath=""):
|
|
|
|
@ -3905,24 +3913,24 @@ re.M|re.S)
|
|
|
|
|
setWARNING = lambda x: self.setWarning(x) and\
|
|
|
|
|
self.printWarning and\
|
|
|
|
|
printObj.printWARNING(x)
|
|
|
|
|
setWARNING(_("No conditions of checking a value of the \
|
|
|
|
|
variable 'cl_name'"))
|
|
|
|
|
setWARNING(_("No conditions of checking the value of "
|
|
|
|
|
"variable 'cl_name'"))
|
|
|
|
|
skipDirTemplates = []
|
|
|
|
|
for skipDir in skipDirs:
|
|
|
|
|
skipTempl = os.path.join(skipDir,self.templDirNameFile)
|
|
|
|
|
if os.path.isfile(skipTempl):
|
|
|
|
|
skipDirTemplates.append(skipTempl)
|
|
|
|
|
if skipTemplates or skipDirTemplates:
|
|
|
|
|
setWARNING(_("Skip templates:"))
|
|
|
|
|
setWARNING(_("Skipped templates:"))
|
|
|
|
|
for skipTemplate in skipTemplates + skipDirTemplates:
|
|
|
|
|
setWARNING(" "*6 + skipTemplate)
|
|
|
|
|
if skipDirs:
|
|
|
|
|
setWARNING(_("Skip directories:"))
|
|
|
|
|
setWARNING(_("Skipped directories:"))
|
|
|
|
|
for skipDir in skipDirs:
|
|
|
|
|
setWARNING(" "*6 + skipDir)
|
|
|
|
|
setWARNING("")
|
|
|
|
|
setWARNING(_("Headers directory and template files first level "\
|
|
|
|
|
"should include of the 'cl_name' variable."))
|
|
|
|
|
setWARNING(_("Headers of directory templates and headers of files "
|
|
|
|
|
"on the first level should include 'cl_name' variable."))
|
|
|
|
|
setWARNING(_("Example:"))
|
|
|
|
|
setWARNING("# Calculate cl_name==calculate-install")
|
|
|
|
|
return skipDirs + skipTemplates
|
|
|
|
@ -3949,7 +3957,7 @@ variable 'cl_name'"))
|
|
|
|
|
return dictTemplates
|
|
|
|
|
|
|
|
|
|
if not self.objVar.defined("cl_template_path"):
|
|
|
|
|
self.setError(_("not defined Var: ") + "cl_template_path")
|
|
|
|
|
self.setError(_("undefined variable: ") + "cl_template_path")
|
|
|
|
|
return False
|
|
|
|
|
dirsTemplates = self.objVar.Get("cl_template_path")
|
|
|
|
|
dirsTemplates.sort()
|
|
|
|
@ -4214,7 +4222,7 @@ variable 'cl_name'"))
|
|
|
|
|
textTemplate = FD.read()
|
|
|
|
|
FD.close()
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error open template") + ": " +\
|
|
|
|
|
self.setError(_("Error in opening template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
|
|
|
|
@ -4245,7 +4253,7 @@ variable 'cl_name'"))
|
|
|
|
|
path = os.path.join(self.homeDir,
|
|
|
|
|
path.partition("/")[2],"")[:-1]
|
|
|
|
|
elif not path or path and path[0] != "/":
|
|
|
|
|
self.setError(_("False value 'path' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'path' in the template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
else:
|
|
|
|
@ -4255,7 +4263,7 @@ variable 'cl_name'"))
|
|
|
|
|
if "name" in objHead.params:
|
|
|
|
|
nameDir = objHead.params['name']
|
|
|
|
|
if "/" in nameDir or nameDir == ".." or nameDir == ".":
|
|
|
|
|
self.setError(_("False value 'name' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'name' in the template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
# Новый путь к директории
|
|
|
|
@ -4274,7 +4282,7 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
removeDir(applyDir)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Can not delete dir: " ) +\
|
|
|
|
|
self.setError(_("Failed to delete the directory: " ) +\
|
|
|
|
|
applyDir)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
|
|
|
|
@ -4288,13 +4296,14 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
removeDir(removePath)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Can not delete dir: " ) +\
|
|
|
|
|
self.setError(
|
|
|
|
|
_("Failed to delete the directory: ") +\
|
|
|
|
|
removePath)
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
os.unlink(removePath)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Can not delete: " ) + removePath)
|
|
|
|
|
self.setError(_("Failed to delete: " ) + removePath)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
|
|
|
|
|
# Созданные директории
|
|
|
|
@ -4312,7 +4321,7 @@ variable 'cl_name'"))
|
|
|
|
|
else:
|
|
|
|
|
os.chmod(applyDir, mode)
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False value 'chmod' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'chmod' in the template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
# chown - изменяем владельца и группу
|
|
|
|
@ -4326,8 +4335,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
uid = pwd.getpwnam(strUid).pw_uid
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Not user in this system: ") + strUid)
|
|
|
|
|
self.setError(_("False value 'chown' in template")+\
|
|
|
|
|
self.setError(_("No such user on the system: ")
|
|
|
|
|
+ strUid)
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template")+\
|
|
|
|
|
": " + templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
gid = self.getGidFromGroup(strGid)
|
|
|
|
@ -4335,8 +4345,9 @@ variable 'cl_name'"))
|
|
|
|
|
import grp
|
|
|
|
|
gid = grp.getgrnam(strGid).gr_gid
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Not group in this system: ")+strGid)
|
|
|
|
|
self.setError(_("False value 'chown' in template") +\
|
|
|
|
|
self.setError(_("Group not found on the system: ")
|
|
|
|
|
+strGid)
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template")+\
|
|
|
|
|
": "+ templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
|
|
|
|
@ -4351,11 +4362,11 @@ variable 'cl_name'"))
|
|
|
|
|
templateDirFile):
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False value 'chown' in template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template") +
|
|
|
|
|
": " + templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False value 'chown' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
else:
|
|
|
|
@ -4472,7 +4483,7 @@ variable 'cl_name'"))
|
|
|
|
|
self.nameFileTemplate = os.path.abspath(nameFileTemplate)
|
|
|
|
|
self.F_TEMPL = self.openTemplFile(self.nameFileTemplate)
|
|
|
|
|
if not self.F_TEMPL:
|
|
|
|
|
self.setError(_("Error open template") + ": " +\
|
|
|
|
|
self.setError(_("Error in opening template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return False
|
|
|
|
|
self.textTemplate = self.F_TEMPL.read()
|
|
|
|
@ -4496,7 +4507,7 @@ variable 'cl_name'"))
|
|
|
|
|
# Получаем путь с заменой ~ на директорию пользователя
|
|
|
|
|
path = os.path.join(self.homeDir,path.partition("/")[2],"")[:-1]
|
|
|
|
|
elif not path or path and path[0] != "/":
|
|
|
|
|
self.setError(_("False value 'path' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'path' in the template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return ([], False)
|
|
|
|
|
else:
|
|
|
|
@ -4507,7 +4518,7 @@ variable 'cl_name'"))
|
|
|
|
|
if objHeadNew.params.has_key("name"):
|
|
|
|
|
nameFile = objHeadNew.params['name']
|
|
|
|
|
if "/" in nameFile or nameFile == ".." or nameFile == ".":
|
|
|
|
|
self.setError(_("False value 'name' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'name' in the template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return ([], False)
|
|
|
|
|
# Новый путь к оригинальному файлу
|
|
|
|
@ -4525,13 +4536,13 @@ variable 'cl_name'"))
|
|
|
|
|
if "exec" in objHeadNew.params:
|
|
|
|
|
execPath = objHeadNew.params['exec']
|
|
|
|
|
if not os.access(execPath,os.X_OK):
|
|
|
|
|
self.setError(_("False value 'exec' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'exec' in the template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not execute %s") %execPath)
|
|
|
|
|
self.setError(_("Failed to execute %s") %execPath)
|
|
|
|
|
return ([], False)
|
|
|
|
|
if typeAppendTemplate == "join":
|
|
|
|
|
self.setError(_("False value 'append=join' in template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Wrong value 'append=join' in the template") +\
|
|
|
|
|
": " + nameFileTemplate)
|
|
|
|
|
return ([], False)
|
|
|
|
|
|
|
|
|
|
# Очищаем оригинальный файл
|
|
|
|
@ -4539,9 +4550,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
open(pathOldFile, "w").truncate(0)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not clear file") + ": " +\
|
|
|
|
|
self.setError(_("Failed to clear the file") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
return (applyFiles, False)
|
|
|
|
|
# Удаляем оригинальный файл
|
|
|
|
@ -4551,9 +4562,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.unlink(pathOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete link") + ": " +\
|
|
|
|
|
self.setError(_("Failed to delete the link") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
if os.path.isfile(pathOldFile):
|
|
|
|
@ -4561,9 +4572,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.remove(pathOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete file") + ": " +\
|
|
|
|
|
self.setError(_("Failed to delete the file") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
return (applyFiles, False)
|
|
|
|
@ -4582,9 +4593,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.unlink(pathOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete link") + ": " +\
|
|
|
|
|
self.setError(_("Failed to delete the link") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
if os.path.isfile(pathOldFile):
|
|
|
|
@ -4592,9 +4603,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.remove(pathOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete file") + ": " +\
|
|
|
|
|
self.setError(_("Failed to delete the file") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
|
|
|
|
@ -4610,10 +4621,10 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.remove(pathOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete file") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
self.setError(_("Failed to delete the file") + \
|
|
|
|
|
": " + pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
elif not os.path.exists(pathOldFile):
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4630,18 +4641,18 @@ variable 'cl_name'"))
|
|
|
|
|
F_CONF.close()
|
|
|
|
|
fMode, fUid, fGid = getModeFile(templateFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not open file") + ": " +\
|
|
|
|
|
self.setError(_("Failed to open the file") + ": " +\
|
|
|
|
|
templateFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
if os.path.exists(pathOldFile):
|
|
|
|
|
try:
|
|
|
|
|
os.remove(pathOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete file") + ": " +\
|
|
|
|
|
self.setError(_("Failed to delete the file") + ": " +\
|
|
|
|
|
pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
if foundTemplateFile:
|
|
|
|
@ -4650,9 +4661,9 @@ variable 'cl_name'"))
|
|
|
|
|
FD.write(buff)
|
|
|
|
|
FD.close()
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not create file") + " '%s'"\
|
|
|
|
|
self.setError(_("Failed to create the file") + " '%s'"\
|
|
|
|
|
%pathOldFile)
|
|
|
|
|
return ([], False)
|
|
|
|
|
oMode = getModeFile(pathOldFile, mode="mode")
|
|
|
|
@ -4673,9 +4684,10 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.chdir(pathLink)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not change the current directory to")+\
|
|
|
|
|
self.setError(
|
|
|
|
|
_("Failed to change the current directory to")+\
|
|
|
|
|
" " + pathLink)
|
|
|
|
|
return ([], False)
|
|
|
|
|
|
|
|
|
@ -4687,7 +4699,7 @@ variable 'cl_name'"))
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False value 'chmod' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'chmod' in the template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4706,9 +4718,10 @@ variable 'cl_name'"))
|
|
|
|
|
if uid is None:
|
|
|
|
|
uid = pwd.getpwnam(strUid).pw_uid
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Not user in this system: ") +
|
|
|
|
|
self.setError(_("No such user on the system: ") +
|
|
|
|
|
strUid)
|
|
|
|
|
self.setError(_("False value 'chown' in template") +
|
|
|
|
|
self.setError(
|
|
|
|
|
_("Wrong value 'chown' in the template") +
|
|
|
|
|
": "+ nameFileTemplate)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4721,9 +4734,10 @@ variable 'cl_name'"))
|
|
|
|
|
import grp
|
|
|
|
|
gid = grp.getgrnam(strGid).gr_gid
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Not group in this system: ") +
|
|
|
|
|
self.setError(_("Group not found on the system: ") +
|
|
|
|
|
strGid)
|
|
|
|
|
self.setError(_("False value 'chown' in template") +
|
|
|
|
|
self.setError(
|
|
|
|
|
_("Wrong value 'chown' in the template") +
|
|
|
|
|
": "+ nameFileTemplate)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4732,12 +4746,12 @@ variable 'cl_name'"))
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False value 'chown' in template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template") +
|
|
|
|
|
": " + nameFileTemplate)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False value 'chown' in template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4766,9 +4780,9 @@ variable 'cl_name'"))
|
|
|
|
|
# иначе удаляем файл
|
|
|
|
|
os.remove(prevOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not delete file") + ": " +\
|
|
|
|
|
self.setError(_("Failed to delete the file") + ": " +\
|
|
|
|
|
prevOldFile)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4779,9 +4793,9 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
os.symlink(pathOldFile, prevOldFile)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error in template") + ": " +\
|
|
|
|
|
self.setError(_("Template error") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not create symbolic link") + " :" +\
|
|
|
|
|
self.setError(_("Failed to create a symbolic link") + " :" +\
|
|
|
|
|
"%s -> %s"%(prevOldFile, pathOldFile))
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
@ -4928,22 +4942,22 @@ variable 'cl_name'"))
|
|
|
|
|
if formatTemplate == "patch":
|
|
|
|
|
if typeAppendTemplate != "patch":
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("False option append=%(type)s in template %(file)s")\
|
|
|
|
|
_("Wrong option append=%(type)s in template %(file)s")\
|
|
|
|
|
%{"type":typeAppendTemplate,"file":nameFileTemplate})
|
|
|
|
|
return False
|
|
|
|
|
# создаем объект формата шаблона
|
|
|
|
|
objTempl = self.getFormatObj(formatTemplate, self.textTemplate)
|
|
|
|
|
if not objTempl:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parmeter format=%s in template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
_("Incorrect header parmeter format=%s in the template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if objHeadOld and objHeadOld.body:
|
|
|
|
|
self.textConfig = objHeadOld.body
|
|
|
|
|
# обработка конфигурационного файла
|
|
|
|
|
self.textTemplate = objTempl.processingFile(self.textConfig)
|
|
|
|
|
if objTempl.getError():
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if execStr:
|
|
|
|
@ -4954,9 +4968,9 @@ variable 'cl_name'"))
|
|
|
|
|
if 'exec' in objHeadNew.params:
|
|
|
|
|
if not self.executeTemplate(self.nameFileConfig,
|
|
|
|
|
objHeadNew.params['exec']):
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not execute") + ": " +\
|
|
|
|
|
self.setError(_("Failed to execute") + ": " +\
|
|
|
|
|
self.nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
@ -4976,12 +4990,12 @@ variable 'cl_name'"))
|
|
|
|
|
self.textTemplate)
|
|
|
|
|
if not objTemplNew:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parmeter format=%s in template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
_("Incorrect header parmeter format=%s in the template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
if objTemplNew.getError():
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
# Имя файла внутри xml xfce конфигурационных файлов
|
|
|
|
@ -5026,9 +5040,9 @@ variable 'cl_name'"))
|
|
|
|
|
if 'exec' in objHeadNew.params:
|
|
|
|
|
if not self.executeTemplate(self.nameFileConfig,
|
|
|
|
|
objHeadNew.params['exec']):
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not execute") + ": " +\
|
|
|
|
|
self.setError(_("Failed to execute") + ": " +\
|
|
|
|
|
self.nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
@ -5037,7 +5051,7 @@ variable 'cl_name'"))
|
|
|
|
|
elif typeAppendTemplate == "before":
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("False option append=before in template %s")\
|
|
|
|
|
_("Wrong option append=before in template %s")\
|
|
|
|
|
%nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if objHeadOld and objHeadOld.body:
|
|
|
|
@ -5055,9 +5069,9 @@ variable 'cl_name'"))
|
|
|
|
|
if 'exec' in objHeadNew.params:
|
|
|
|
|
if not self.executeTemplate(self.nameFileConfig,
|
|
|
|
|
objHeadNew.params['exec']):
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not execute") + ": " +\
|
|
|
|
|
self.setError(_("Failed to execute") + ": " +\
|
|
|
|
|
self.nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
@ -5066,7 +5080,7 @@ variable 'cl_name'"))
|
|
|
|
|
elif typeAppendTemplate == "after":
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("False option append=after in template %s")\
|
|
|
|
|
_("Wrong option append=after in template %s")\
|
|
|
|
|
%nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if objHeadOld and objHeadOld.body:
|
|
|
|
@ -5083,9 +5097,9 @@ variable 'cl_name'"))
|
|
|
|
|
if 'exec' in objHeadNew.params:
|
|
|
|
|
if not self.executeTemplate(self.nameFileConfig,
|
|
|
|
|
objHeadNew.params['exec']):
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not execute") + ": " +\
|
|
|
|
|
self.setError(_("Failed to execute") + ": " +\
|
|
|
|
|
self.nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
@ -5097,20 +5111,20 @@ variable 'cl_name'"))
|
|
|
|
|
self.textTemplate = objTxtCoder.encode(self.textTemplate)
|
|
|
|
|
if formatTemplate =="raw":
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parmeter append=%s in template")\
|
|
|
|
|
%typeAppendTemplate + " " + nameFileTemplate)
|
|
|
|
|
_("Incorrect header parmeter append=%s in the template")\
|
|
|
|
|
%typeAppendTemplate + " " + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
# создаем объект формата шаблона
|
|
|
|
|
objTemplNew = self.getFormatObj(formatTemplate,
|
|
|
|
|
self.textTemplate)
|
|
|
|
|
if not objTemplNew:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parmeter format=%s in template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
_("Incorrect header parmeter format=%s in the template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
if objTemplNew.getError():
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
nameRootNode=nameFileConfig.rpartition("/")[2].split(".")[0]
|
|
|
|
@ -5145,7 +5159,7 @@ variable 'cl_name'"))
|
|
|
|
|
return False
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
if objTemplOld.getError():
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
nameRootNode=nameFileConfig.rpartition("/")[2].split(".")[0]
|
|
|
|
@ -5154,7 +5168,7 @@ variable 'cl_name'"))
|
|
|
|
|
objTemplOld.join(objTemplNew)
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
if objTemplOld.getError():
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
data = objTemplOld.getConfig().encode("UTF-8").split("\n")
|
|
|
|
@ -5175,19 +5189,19 @@ variable 'cl_name'"))
|
|
|
|
|
if 'exec' in objHeadNew.params:
|
|
|
|
|
if not self.executeTemplate(self.nameFileConfig,
|
|
|
|
|
objHeadNew.params['exec']):
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Can not execute") + ": " +\
|
|
|
|
|
self.setError(_("Failed to execute") + ": " +\
|
|
|
|
|
self.nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
|
return filesApply
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("False (type append) template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong (type append) template") + ": " +\
|
|
|
|
|
typeAppendTemplate)
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
self.setError(_("Type template not found: ") + nameFileTemplate)
|
|
|
|
|
self.setError(_("Template type not found: ") + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
return filesApply
|
|
|
|
|
|
|
|
|
@ -5325,7 +5339,7 @@ class templateClt(scanDirectoryClt, template):
|
|
|
|
|
if not self.flagApplyTemplates:
|
|
|
|
|
return ([],[])
|
|
|
|
|
if not self.objVar.defined("cl_template_clt_path"):
|
|
|
|
|
self.setError(_("not defined Var: ") + "cl_template_clt_path")
|
|
|
|
|
self.setError(_("undefined variable: ") + "cl_template_clt_path")
|
|
|
|
|
return False
|
|
|
|
|
dirsTemplates = self.objVar.Get("cl_template_clt_path")
|
|
|
|
|
dirsTemplates.sort()
|
|
|
|
@ -5398,7 +5412,8 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
|
|
|
|
|
def writeIniFile(self, txtConfig):
|
|
|
|
|
if self.readOnly:
|
|
|
|
|
self.setError(_("Unable to write into file") + ": " + self.iniFile)
|
|
|
|
|
self.setError(_("Unable to write to the file") +
|
|
|
|
|
": " + self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
if not os.path.exists(self.iniFile):
|
|
|
|
|
try:
|
|
|
|
@ -5407,10 +5422,12 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
fcntl.flock(self.FD.fileno(), fcntl.LOCK_EX)
|
|
|
|
|
os.chmod(self.iniFile, self.mode)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Unable to create file") + ": " + self.iniFile)
|
|
|
|
|
self.setError(_("Unable to create the file") +
|
|
|
|
|
": " + self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
if not self.FD:
|
|
|
|
|
self.setError(_("Unable to write into file") + ": " + self.iniFile)
|
|
|
|
|
self.setError(_("Unable to write to the file") +
|
|
|
|
|
": " + self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
self.FD.truncate(0)
|
|
|
|
|
self.FD.seek(0)
|
|
|
|
@ -5435,8 +5452,8 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
classObj = self.getClassObj("plasma")
|
|
|
|
|
else:
|
|
|
|
|
if nameFomat == "plasma":
|
|
|
|
|
self.setError(_("In the file %s (format - 'plasma'), "\
|
|
|
|
|
"write the variable in the format 'samba'")\
|
|
|
|
|
self.setError(_("Trying to write a variable of 'samba' format"
|
|
|
|
|
" to file %s (format - 'plasma')")
|
|
|
|
|
%self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
# формат samba
|
|
|
|
@ -5487,7 +5504,7 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
try:
|
|
|
|
|
objIni = self.getClassObj("plasma")(textIni)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Incorrect format file") + ": " + \
|
|
|
|
|
self.setError(_("Incorrect file format") + ": " + \
|
|
|
|
|
self.iniFile)
|
|
|
|
|
self.checkIni = False
|
|
|
|
|
return self.checkIni
|
|
|
|
@ -5540,8 +5557,8 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
formatPlasma = True
|
|
|
|
|
else:
|
|
|
|
|
if nameFomat == "plasma":
|
|
|
|
|
self.setError(_("In the file %s (format - 'plasma'), "\
|
|
|
|
|
"get the variable in the format 'samba'")\
|
|
|
|
|
self.setError(_("Trying to fetch a variable of 'samba' format"
|
|
|
|
|
" from file %s (format - 'plasma')")\
|
|
|
|
|
%self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
# формат samba
|
|
|
|
@ -5607,8 +5624,8 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
formatPlasma = True
|
|
|
|
|
else:
|
|
|
|
|
if nameFomat == "plasma":
|
|
|
|
|
self.setError(_("In the file %s (format - 'plasma'), "\
|
|
|
|
|
"get all variables in the format 'samba'")\
|
|
|
|
|
self.setError(_("Trying to fetch all variables of 'samba' "
|
|
|
|
|
"format from file %s (format - 'plasma')")
|
|
|
|
|
%self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
# формат samba
|
|
|
|
|