|
|
|
@ -335,7 +335,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)
|
|
|
|
@ -570,7 +570,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,
|
|
|
|
@ -717,7 +717,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)
|
|
|
|
@ -2106,7 +2106,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
|
|
|
|
@ -2117,7 +2118,8 @@ class _file(_error):
|
|
|
|
|
try:
|
|
|
|
|
F_TEMPL = open(nameFileTemplate, "r")
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("not open file:" ) + nameFileTemplate)
|
|
|
|
|
self.setError(_("unable to open the file:")
|
|
|
|
|
+ nameFileConfig)
|
|
|
|
|
return False
|
|
|
|
|
return F_TEMPL
|
|
|
|
|
|
|
|
|
@ -2143,7 +2145,8 @@ 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
|
|
|
|
|
|
|
|
|
@ -2401,13 +2404,13 @@ class _shareTemplate:
|
|
|
|
|
gid = pwdObj.pw_gid
|
|
|
|
|
homeDir = pwdObj.pw_dir
|
|
|
|
|
except:
|
|
|
|
|
raise TemplatesError(_("Can not found user %s")%str(userName))
|
|
|
|
|
raise TemplatesError(_("User %s not found")%str(userName))
|
|
|
|
|
if groupsInfo:
|
|
|
|
|
import grp
|
|
|
|
|
try:
|
|
|
|
|
groupName = grp.getgrgid(gid).gr_name
|
|
|
|
|
except:
|
|
|
|
|
raise TemplatesError(_("Can not found group id %s")%str(gid))
|
|
|
|
|
raise TemplatesError(_("Group id %s not found")%str(gid))
|
|
|
|
|
groupsNames = map(lambda x: x.gr_name,\
|
|
|
|
|
filter(lambda x: userName in x.gr_mem, grp.getgrall()))
|
|
|
|
|
groupsNames = [groupName] + groupsNames
|
|
|
|
@ -2633,7 +2636,7 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
flagNotRootFS = False
|
|
|
|
|
else:
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
|
_("Second argument function is not 'root'"))
|
|
|
|
|
_("The second argument function is not 'root'"))
|
|
|
|
|
if fileName[0] == "~":
|
|
|
|
|
# Получаем директорию пользователя
|
|
|
|
|
fileName = os.path.join(self.homeDir,
|
|
|
|
@ -2672,12 +2675,12 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
flagNotRootFS = False
|
|
|
|
|
else:
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
|
_("Third argument function is not 'root'"))
|
|
|
|
|
_("The third argument of the function is not 'root'"))
|
|
|
|
|
if lenTerms >= 2:
|
|
|
|
|
if not terms[0] in ["ver","num","char","key","empty"]:
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
|
_("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'"))
|
|
|
|
|
if lenTerms == 1:
|
|
|
|
|
fileName = terms[0].strip()
|
|
|
|
|
else:
|
|
|
|
@ -2806,7 +2809,7 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
lenStr = int(terms[1])
|
|
|
|
|
except:
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
|
_("two argument function is not number"))
|
|
|
|
|
_("the second argument of the function is not a number"))
|
|
|
|
|
choiceStr = fArgvNames[terms[0]]
|
|
|
|
|
replace = ''.join([random.choice(choiceStr) for i in xrange(lenStr)])
|
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
|
@ -2829,8 +2832,9 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
self.raiseErrTemplate()
|
|
|
|
|
fArgvNames = ['upper','lower','capitalize']
|
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
|
self.raiseErrTemplate(_("first argument function is not 'upper' \
|
|
|
|
|
or 'lower' or 'capitalize'"))
|
|
|
|
|
self.raiseErrTemplate(_("the first argument of the function"
|
|
|
|
|
" is not 'upper' or 'lower' or"
|
|
|
|
|
" 'capitalize'"))
|
|
|
|
|
try:
|
|
|
|
|
strValue = str(self.objVar.Get(terms[1]))
|
|
|
|
|
except:
|
|
|
|
@ -3009,8 +3013,9 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
self.currDictIni[nameLocVar] = valueLocVar
|
|
|
|
|
elif len(terms) == 3:
|
|
|
|
|
if not terms[2] in ['url','purl','unicode']:
|
|
|
|
|
self.raiseErrTemplate(_("third argument function is not "
|
|
|
|
|
"'url' or 'purl' or 'unicode'"))
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
|
_("the third argument of the function is not "
|
|
|
|
|
"'url' or 'purl' or 'unicode'"))
|
|
|
|
|
if terms[1]:
|
|
|
|
|
self.raiseErrTemplate()
|
|
|
|
|
if self.timeIni != curTime:
|
|
|
|
@ -3230,7 +3235,7 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
|
if not type(value) in (list,tuple):
|
|
|
|
|
# Значение переменной не список или кортеж
|
|
|
|
|
self.raiseErrTemplate(_("value of %s is not a list or tuple")\
|
|
|
|
|
self.raiseErrTemplate(_("value of %s is not a list or a tuple")\
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
|
try:
|
|
|
|
|
if len(value) > intIndex:
|
|
|
|
@ -3238,7 +3243,7 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
else:
|
|
|
|
|
replace = ""
|
|
|
|
|
except:
|
|
|
|
|
self.raiseErrTemplate(_("%s wrong")%strIndex)
|
|
|
|
|
self.raiseErrTemplate(_("wrong %s")%strIndex)
|
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
|
|
textTemplateTmp[resS.end():]
|
|
|
|
|
return textTemplateTmp
|
|
|
|
@ -3261,7 +3266,7 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
mountPoint = terms[0]
|
|
|
|
|
lastElementVar = terms[1]
|
|
|
|
|
if not mountPoint or mountPoint[:1] !="/":
|
|
|
|
|
self.raiseErrTemplate(_("%s wrong")%lastElementVar)
|
|
|
|
|
self.raiseErrTemplate(_("wrong %s")%lastElementVar)
|
|
|
|
|
nameVar = "os_install_disk_mount"
|
|
|
|
|
try:
|
|
|
|
|
valueVar = self.objVar.Get(nameVar)
|
|
|
|
@ -3278,16 +3283,16 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
try:
|
|
|
|
|
valueElementVar = self.objVar.Get(nameElementVar)
|
|
|
|
|
except:
|
|
|
|
|
self.raiseErrTemplate(_("%s wrong")%lastElementVar+"\n"+
|
|
|
|
|
self.raiseErrTemplate(_("wrong %s")%lastElementVar+"\n"+
|
|
|
|
|
_("error: variable %s is not exists")\
|
|
|
|
|
%nameElementVar)
|
|
|
|
|
if not type(valueVar) in (list,tuple):
|
|
|
|
|
# Значение переменной не список или кортеж
|
|
|
|
|
self.raiseErrTemplate(_("value of %s is not a list or tuple")\
|
|
|
|
|
self.raiseErrTemplate(_("value of %s is not a list or a tuple")\
|
|
|
|
|
%nameVar)
|
|
|
|
|
if not type(valueElementVar) in (list,tuple):
|
|
|
|
|
# Значение переменной не список или кортеж
|
|
|
|
|
self.raiseErrTemplate(_("value of %s is not a list or tuple")\
|
|
|
|
|
self.raiseErrTemplate(_("value of %s is not a list or a tuple")\
|
|
|
|
|
%nameElementVar)
|
|
|
|
|
if len(valueVar) != len(valueElementVar):
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
@ -3304,8 +3309,9 @@ or 'lower' or 'capitalize'"))
|
|
|
|
|
index = num
|
|
|
|
|
break
|
|
|
|
|
if index is None:
|
|
|
|
|
self.raiseErrTemplate(_("in the value of the variable \
|
|
|
|
|
os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
self.raiseErrTemplate(_("mount point '/' or '/%s' not found "
|
|
|
|
|
" in the value of the variable os_disk_install")
|
|
|
|
|
%mountPoint)
|
|
|
|
|
replace = valueElementVar[index]
|
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
|
|
textTemplateTmp[resS.end():]
|
|
|
|
@ -3353,7 +3359,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
message = ""
|
|
|
|
|
raise TemplatesError(
|
|
|
|
|
_("error in template %s")%self.nameTemplate + "\n" + \
|
|
|
|
|
_("error template term '%s'")%str(self.functText) + \
|
|
|
|
|
_("error, template term '%s'")%str(self.functText) + \
|
|
|
|
|
message)
|
|
|
|
|
|
|
|
|
|
def applyFuncTemplate(self, textTemplate, nameTemplate):
|
|
|
|
@ -3383,7 +3389,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
|
|
|
|
|
flagIniFunc = True
|
|
|
|
|
else:
|
|
|
|
|
self.raiseErrTemplate(
|
|
|
|
|
_("can not found template function '%s'")\
|
|
|
|
|
_("function of templates '%s' not found")\
|
|
|
|
|
%str(self.functText))
|
|
|
|
|
if flagIniFunc:
|
|
|
|
|
# Очистка файла в случае его ошибочного чтения
|
|
|
|
@ -3563,7 +3569,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:
|
|
|
|
@ -3602,7 +3608,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
|
|
|
|
@ -3620,7 +3626,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:
|
|
|
|
@ -3631,7 +3638,8 @@ 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
|
|
|
|
|
|
|
|
|
@ -3672,7 +3680,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:
|
|
|
|
@ -3689,7 +3697,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
|
|
|
|
@ -3700,7 +3708,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=""):
|
|
|
|
@ -3845,24 +3853,25 @@ 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
|
|
|
|
@ -3889,7 +3898,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")
|
|
|
|
|
# Созданные директории
|
|
|
|
@ -4174,7 +4183,7 @@ variable 'cl_name'"))
|
|
|
|
|
textTemplate = FD.read()
|
|
|
|
|
FD.close()
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Error open template") + ": " +\
|
|
|
|
|
self.setError(_("Error in opening template") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
|
|
|
|
@ -4205,7 +4214,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:
|
|
|
|
@ -4215,7 +4224,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, [])
|
|
|
|
|
# Новый путь к директории
|
|
|
|
@ -4234,7 +4243,7 @@ variable 'cl_name'"))
|
|
|
|
|
try:
|
|
|
|
|
removeDir(applyDir)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Can not delete dir: " ) +\
|
|
|
|
|
self.setError(_("Failed to delete the directory: ") +\
|
|
|
|
|
applyDir)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
|
|
|
|
@ -4248,13 +4257,15 @@ 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, [])
|
|
|
|
|
|
|
|
|
|
# Созданные директории
|
|
|
|
@ -4272,7 +4283,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 - изменяем владельца и группу
|
|
|
|
@ -4286,8 +4297,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)
|
|
|
|
@ -4295,8 +4307,10 @@ 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, [])
|
|
|
|
|
|
|
|
|
@ -4311,12 +4325,12 @@ 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") + ": " +\
|
|
|
|
|
templateDirFile)
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template") +
|
|
|
|
|
": " + templateDirFile)
|
|
|
|
|
return ("", False, [])
|
|
|
|
|
else:
|
|
|
|
|
# Устанавливаем владельцем директории, пользователя по умолчанию
|
|
|
|
@ -4438,7 +4452,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()
|
|
|
|
@ -4458,7 +4472,7 @@ variable 'cl_name'"))
|
|
|
|
|
mergePkgs = objHeadNew.params['merge'].split(',')
|
|
|
|
|
reRight = re.compile(r'^(\w+-\w+/)?[\w-]+$')
|
|
|
|
|
for wrongPkg in (x for x in mergePkgs if not reRight.match(x)):
|
|
|
|
|
self.setError(_("Wrong value '%s' for 'merge' in template")%
|
|
|
|
|
self.setError(_("Wrong value '%s' for 'merge' in the template")%
|
|
|
|
|
wrongPkg + ": " + nameFileTemplate)
|
|
|
|
|
return ([], False)
|
|
|
|
|
for pkg in mergePkgs:
|
|
|
|
@ -4475,7 +4489,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:
|
|
|
|
@ -4486,7 +4500,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)
|
|
|
|
|
# Новый путь к оригинальному файлу
|
|
|
|
@ -4504,12 +4518,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") + ": " +\
|
|
|
|
|
self.setError(_("Wrong value 'append=join' in the template") +
|
|
|
|
|
": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return ([], False)
|
|
|
|
|
|
|
|
|
@ -4518,9 +4533,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)
|
|
|
|
|
# Удаляем оригинальный файл
|
|
|
|
@ -4530,9 +4545,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):
|
|
|
|
@ -4540,9 +4555,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)
|
|
|
|
@ -4561,9 +4576,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):
|
|
|
|
@ -4571,9 +4586,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)
|
|
|
|
|
|
|
|
|
@ -4589,9 +4604,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)
|
|
|
|
|
elif not os.path.exists(pathOldFile):
|
|
|
|
@ -4609,18 +4624,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:
|
|
|
|
@ -4629,9 +4644,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")
|
|
|
|
@ -4656,9 +4671,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)
|
|
|
|
|
|
|
|
|
@ -4670,7 +4686,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)
|
|
|
|
@ -4689,9 +4705,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)
|
|
|
|
@ -4704,9 +4721,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)
|
|
|
|
@ -4715,13 +4733,13 @@ 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") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
self.setError(_("Wrong value 'chown' in the template")
|
|
|
|
|
+ ": " + nameFileTemplate)
|
|
|
|
|
preReturn(pathProg)
|
|
|
|
|
return ([], False)
|
|
|
|
|
if not flagSymlink:
|
|
|
|
@ -4749,9 +4767,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)
|
|
|
|
@ -4762,9 +4780,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)
|
|
|
|
@ -4911,14 +4929,15 @@ 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 parameter format=%s in template")\
|
|
|
|
|
_("Incorrect header parameter format=%s "
|
|
|
|
|
"in the template")\
|
|
|
|
|
%formatTemplate + " " + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if objHeadOld and objHeadOld.body:
|
|
|
|
@ -4926,7 +4945,7 @@ variable 'cl_name'"))
|
|
|
|
|
# обработка конфигурационного файла
|
|
|
|
|
self.textTemplate = objTempl.processingFile(self.textConfig)
|
|
|
|
|
if objTempl.getError():
|
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
|
self.setError(_("Wrong template") + ": " +\
|
|
|
|
|
nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
if execStr:
|
|
|
|
@ -4937,9 +4956,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
|
|
|
|
@ -4959,12 +4978,13 @@ variable 'cl_name'"))
|
|
|
|
|
self.textTemplate)
|
|
|
|
|
if not objTemplNew:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parameter format=%s in template")\
|
|
|
|
|
_("Incorrect header parameter 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 конфигурационных файлов
|
|
|
|
@ -5009,9 +5029,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
|
|
|
|
@ -5020,7 +5040,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:
|
|
|
|
@ -5038,9 +5058,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
|
|
|
|
@ -5049,7 +5069,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:
|
|
|
|
@ -5066,9 +5086,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
|
|
|
|
@ -5080,7 +5100,8 @@ variable 'cl_name'"))
|
|
|
|
|
self.textTemplate = objTxtCoder.encode(self.textTemplate)
|
|
|
|
|
if formatTemplate =="raw":
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parameter append=%s in template")\
|
|
|
|
|
_("Incorrect header parameter append=%s "
|
|
|
|
|
"in the template")\
|
|
|
|
|
%typeAppendTemplate + " " + nameFileTemplate)
|
|
|
|
|
return False
|
|
|
|
|
# создаем объект формата шаблона
|
|
|
|
@ -5088,12 +5109,13 @@ variable 'cl_name'"))
|
|
|
|
|
self.textTemplate)
|
|
|
|
|
if not objTemplNew:
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Incorrect header parameter format=%s in template")\
|
|
|
|
|
_("Incorrect header parameter 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]
|
|
|
|
@ -5128,7 +5150,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]
|
|
|
|
@ -5137,7 +5159,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")
|
|
|
|
@ -5158,19 +5180,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
|
|
|
|
|
|
|
|
|
@ -5306,7 +5328,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()
|
|
|
|
@ -5379,7 +5401,7 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
|
|
|
|
|
def writeIniFile(self, txtConfig):
|
|
|
|
|
if self.readOnly:
|
|
|
|
|
self.setError(_("Unable to write into file") + ": " + self.iniFile)
|
|
|
|
|
self.setError(_("Failed to write to file") + ": " + self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
if not os.path.exists(self.iniFile):
|
|
|
|
|
try:
|
|
|
|
@ -5388,10 +5410,11 @@ class iniParser(_error, templateFormat):
|
|
|
|
|
fcntl.flock(self.FD.fileno(), fcntl.LOCK_EX)
|
|
|
|
|
os.chmod(self.iniFile, self.mode)
|
|
|
|
|
except:
|
|
|
|
|
self.setError(_("Failed to create the file") + ": " + self.iniFile)
|
|
|
|
|
self.setError(_("Failed to create the file") +
|
|
|
|
|
": " + self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
if not self.FD:
|
|
|
|
|
self.setError(_("Unable to write into file") + ": " + self.iniFile)
|
|
|
|
|
self.setError(_("Failed to write to file") + ": " + self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
self.FD.truncate(0)
|
|
|
|
|
self.FD.seek(0)
|
|
|
|
@ -5416,8 +5439,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
|
|
|
|
@ -5468,7 +5491,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
|
|
|
|
@ -5521,8 +5544,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
|
|
|
|
@ -5588,8 +5611,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 a variable of 'samba' "
|
|
|
|
|
"format from file %s (format - 'plasma')")\
|
|
|
|
|
%self.iniFile)
|
|
|
|
|
return False
|
|
|
|
|
# формат samba
|
|
|
|
|