Modified algorithm of auto update configuration files.

develop
Самоукин Алексей 14 years ago
parent 561abab937
commit 256b307839

@ -240,6 +240,51 @@ class updateSystemConfigs(shareUpdateConfigs):
configFiles = map(lambda x: x.partition(configPath)[2], configFiles)
return configFiles
def createDir(self, configPath, dstDir):
"""Создание директории в случае необходимости"""
if os.path.exists(dstDir):
return True
def splPath(path):
listPath = []
if path in ("","/"):
return []
base, p = os.path.split(path)
listPath.append(p)
while(not base in ("","/")):
base, p = os.path.split(base)
listPath.append(p)
listPath.reverse()
return listPath
notFoundPaths = []
path = "/"
for p in splPath(dstDir):
path = os.path.join(path,p)
if not os.path.exists(path):
notFoundPaths.append(path)
for mkPath in notFoundPaths:
srcPath = pathJoin(configPath, mkPath)
dMode, dUid, dGid = getModeFile(srcPath)
os.mkdir(mkPath, dMode)
os.chown(mkPath, dUid, dGid)
return True
def copyConfigFiles(self, configPath):
"""Копирование конфигурационных файлов"""
configDstFiles = self.scanProtectDirs(configPath)
if configDstFiles:
self.logger.warn(_("Replace files:"))
for dst in configDstFiles:
src = pathJoin(configPath, dst)
if src != dst:
dstDir = os.path.dirname(dst)
self.createDir(configPath, dstDir)
copy2(src, dst)
sUid, sGid = getModeFile(src, mode="owner")
os.chown(dst, sUid, sGid)
self.logger.warn(" "*5 + dst)
return True
def updateConfig(self, nameProgram, category, version, configPath):
"""Обновление системных конфигурационных файлов"""
# флаг обновления и программы используемые для наложения шаблонов
@ -303,16 +348,11 @@ class updateSystemConfigs(shareUpdateConfigs):
nameFile = nameF.partition(configPath)[2]
if nameFile[:1] != "/":
nameFile = "/" + nameFile
if flagUpdate:
src = nameF
dst = nameFile
if src != dst:
copy2(src, dst)
sUid, sGid = getModeFile(src, mode="owner")
os.chown(dst, sUid, sGid)
self.printWARNING(" "*5 + nameFile)
else:
self.logger.warn(_("Not found templates"))
if flagUpdate:
self.copyConfigFiles(configPath)
if clTempl and clTempl.getWarning():
cl_overriding.printSUCCESS("")
for warn in clTempl.getWarning().split("\n"):

Loading…
Cancel
Save