master
asamoukin 16 years ago
parent 39a0baa264
commit 20246a00e8

@ -398,7 +398,7 @@ class iniParser(cl_profile._error):
# находим в области переменную
res = objIni.docObj.getAreaFieldValues(strHeader, nameVar, xmlBody)
if res == False:
return None
return ""
else:
return res
@ -445,7 +445,7 @@ class var:
#(Global, Builder, Client, Server итд)
service = None
# значение переменной
value = None
value = ""
# режим записи (атрибут mode)
mode = "r"
# переменная для внутреннего использования (official)
@ -637,7 +637,7 @@ class DataVars(object):
return True
def __Get(self, nameVar):
ret = None
ret = ""
self.__LevelsVar.append((self.__levelNumber, nameVar))
self.__levelNumber += 1
#nameMethod = "get_" + nameVar
@ -652,8 +652,6 @@ class DataVars(object):
varobj.Fill = methodFill
self.__setattr__(nameVar, varobj)
ret = self.__getattribute__(nameVar).Get()
else:
ret = None
self.__levelNumber -= 1
if self.__levelNumber == 0 and\
self.__getattribute__(nameVar).fillStart and\
@ -725,7 +723,7 @@ class DataVars(object):
links[name] = {}
for lv, nm in fr:
if level == lv:
links[name][nm] = None
links[name][nm] = ""
return links
def __getPathCalculateIni(self):

@ -2138,9 +2138,10 @@ class profile(_file, _terms):
profTitle = '"' + "/".join(listProfTitle) + '"'
# Записываем в переменную обрабатываемый файл
self.objVar.Set("cl_pass_file",oldFile)
self.join(fileProfile, oldFile,
filesApl = self.join(fileProfile, oldFile,
(self.objVar.Get("cl_ver"),profTitle))
filesApply.append(oldFile)
if filesApl:
filesApply += filesApl
else:
if self.getError():
print self.getError()
@ -2151,6 +2152,8 @@ class profile(_file, _terms):
def __getApplyHeadProfile(self ,newFile, oldFile, copyFile):
"""Применяет заголовок к профилю (права, владелец, и.т. д)"""
self.closeFiles()
# Файлы в системе к которым были применены профили
applyFiles = [oldFile]
if copyFile:
self.nameFileNew = self.absFileName(newFile)
self.FN = self.openNewFile(self.nameFileNew)
@ -2159,7 +2162,7 @@ class profile(_file, _terms):
objHeadNew = calcHeader(self.newProfile, False,
self.getFileType(),objVar=self.objVar)
if not objHeadNew.headerTerm:
return False
return (applyFiles, False)
flagSymlink = False
flagForce = False
# Если есть параметр mirror
@ -2169,9 +2172,9 @@ class profile(_file, _terms):
if not os.path.exists(profileFile):
if os.path.exists(oldFile):
os.remove(oldFile)
return False
return (applyFiles, False)
elif not os.path.exists(oldFile):
return False
return (applyFiles, False)
# Если есть указатель на файл профиля (link)
if objHeadNew.params.has_key("link") and\
not objHeadNew.params.has_key("symbolic"):
@ -2228,7 +2231,7 @@ class profile(_file, _terms):
else:
self.setError (_("False value 'chmod' in profile: " ) +\
newFile)
return False
return (applyFiles, False)
# chown - изменяем владельца и группу
if objHeadNew.params.has_key("chown"):
@ -2243,7 +2246,7 @@ class profile(_file, _terms):
self.setError (_("Not user in this system: ") + strUid)
self.setError (_("False value 'chown' in profile: " )+\
newFile)
return False
return (applyFiles, False)
try:
import grp
gid = grp.getgrnam(strGid)[2]
@ -2251,7 +2254,7 @@ class profile(_file, _terms):
self.setError (_("Not group in this system: ")+strGid)
self.setError (_("False value 'chown' in profile: " )+\
newFile)
return False
return (applyFiles, False)
if not os.path.exists(oldFile):
FO = self.openNewFile(newFile)
@ -2263,11 +2266,11 @@ class profile(_file, _terms):
else:
self.setError (_("False value 'chown' in profile: " ) +\
newFile)
return False
return (applyFiles, False)
else:
self.setError (_("False value 'chown' in profile: " ) +\
newFile)
return False
return (applyFiles, False)
self.openFiles(newFile, oldFile)
if flagSymlink:
@ -2280,12 +2283,16 @@ class profile(_file, _terms):
os.remove(prevOldFile)
if not "/" == oldFile[0]:
os.symlink(oldFile, prevOldFile)
applyFiles = [prevOldFile,os.path.join(pathLink,oldFile)]
os.chdir(pathProg)
else:
os.symlink(oldFile, prevOldFile)
applyFiles = [prevOldFile,oldFile]
if not objHeadNew.body.strip():
return False
return objHeadNew
return (applyFiles, False)
else:
applyFiles = [oldFile]
return (applyFiles, objHeadNew)
def createNewClass(self, name, bases, attrs={}):
"""Создает объект нового класса
@ -2334,9 +2341,10 @@ class profile(_file, _terms):
self.newProfile = self.applyFuncProfile(self.newProfile,
newFile)
copyFile = False
objHeadNew = self.__getApplyHeadProfile(newFile, oldFile, copyFile)
filesApply, objHeadNew = self.__getApplyHeadProfile(newFile, oldFile,
copyFile)
if not objHeadNew:
return True
return filesApply
self.newProfile = objHeadNew.body
#if objHeadNew.fileType != "bin":
#self.newProfile = self.applyTermsProfile(self.newProfile,
@ -2402,7 +2410,7 @@ class profile(_file, _terms):
else:
self.oldProfile = title + self.newProfile
self.saveOldFile()
return True
return filesApply
# Впереди
elif objHeadNew.typeAppend == "before":
if objHeadOld and objHeadOld.body:
@ -2420,7 +2428,7 @@ class profile(_file, _terms):
#print self.oldProfile
self.saveOldFile()
return True
return filesApply
# Cзади
elif objHeadNew.typeAppend == "after":
if objHeadOld and objHeadOld.body:
@ -2436,7 +2444,7 @@ class profile(_file, _terms):
else:
self.oldProfile = title + tmpProfile
self.saveOldFile()
return True
return filesApply
# Объединение
elif objHeadNew.typeAppend == "join":
try:
@ -2504,7 +2512,7 @@ class profile(_file, _terms):
self.oldProfile = title +\
objProfOld.getConfig().encode("UTF-8")
self.saveOldFile()
return True
return filesApply
else:
self.setError (_("False (type append) profile: " ) +\
objHeadNew.typeAppend)
@ -2512,6 +2520,7 @@ class profile(_file, _terms):
else:
self.setError (_("Type profile not found: ") + newFile)
return False
return filesApply
class samba(objShare):
"""Класс для обработки конфигурационного файла типа samba

Loading…
Cancel
Save