|
|
|
@ -2383,6 +2383,11 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
# Время модификации конфигурационного файла для ini()
|
|
|
|
|
self.timeIni = -1
|
|
|
|
|
self.uid, self.gid, self.homeDir = self.getDataUser()
|
|
|
|
|
# Путь к конфигурационному файлу для ini()
|
|
|
|
|
self.pathConfigIni = os.path.join(self.homeDir, ".calculate")
|
|
|
|
|
self.fileConfigIni = os.path.join(self.pathConfigIni,"ini.env")
|
|
|
|
|
# Словарь времен модификации env файлов
|
|
|
|
|
self.timeConfigsIni = {}
|
|
|
|
|
|
|
|
|
|
def getDataUser(self):
|
|
|
|
|
"""Получить информацию о пользователе"""
|
|
|
|
@ -2914,15 +2919,8 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
|
|
|
|
|
def getTimeFile(fileName):
|
|
|
|
|
# Получаем время модификации файла
|
|
|
|
|
try:
|
|
|
|
|
stInfo = os.lstat(fileName)
|
|
|
|
|
statInfo = stInfo[stat.ST_MODE]
|
|
|
|
|
except:
|
|
|
|
|
return 0
|
|
|
|
|
# Проверяем существование файла
|
|
|
|
|
if stat.S_ISREG(statInfo):
|
|
|
|
|
# Получаем метку времени конфигурационного файла
|
|
|
|
|
return stInfo[stat.ST_CTIME]
|
|
|
|
|
if fileName in self.timeConfigsIni:
|
|
|
|
|
return self.timeConfigsIni[fileName]
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
def funcIni(funTxt, resS, textProfileTmp):
|
|
|
|
@ -2930,13 +2928,10 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
|
|
|
|
|
из ini файла ~./calculate/ini.env
|
|
|
|
|
"""
|
|
|
|
|
# ~/.calculate
|
|
|
|
|
pathConfig = os.path.join(self.homeDir, ".calculate")
|
|
|
|
|
fileConfig = os.path.join(pathConfig,"ini.env")
|
|
|
|
|
# Создаем директорию
|
|
|
|
|
if not os.path.exists(pathConfig):
|
|
|
|
|
os.makedirs(pathConfig)
|
|
|
|
|
os.chown(pathConfig, int(self.uid), int(self.gid))
|
|
|
|
|
if not os.path.exists(self.pathConfigIni):
|
|
|
|
|
os.makedirs(self.pathConfigIni)
|
|
|
|
|
os.chown(self.pathConfigIni, int(self.uid), int(self.gid))
|
|
|
|
|
termsRaw = funTxt[4:-1].split(",")
|
|
|
|
|
flagFirst = True
|
|
|
|
|
terms = []
|
|
|
|
@ -2966,21 +2961,21 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
cl_base.exit(1)
|
|
|
|
|
replace = ""
|
|
|
|
|
# Получаем время модификации конфигурационного файла
|
|
|
|
|
curTime = getTimeFile(fileConfig)
|
|
|
|
|
curTime = getTimeFile(self.fileConfigIni)
|
|
|
|
|
if len(terms) == 1:
|
|
|
|
|
if self.timeIni != curTime:
|
|
|
|
|
# читаем переменные из файла
|
|
|
|
|
self.prevDictIni = loadVarsIni(fileConfig)
|
|
|
|
|
self.prevDictIni = loadVarsIni(self.fileConfigIni)
|
|
|
|
|
self.currDictIni.update(self.prevDictIni)
|
|
|
|
|
self.timeIni = getTimeFile(fileConfig)
|
|
|
|
|
self.timeIni = getTimeFile(self.fileConfigIni)
|
|
|
|
|
if nameLocVar in self.currDictIni.keys():
|
|
|
|
|
replace = self.currDictIni[nameLocVar]
|
|
|
|
|
elif len(terms) == 2:
|
|
|
|
|
if self.timeIni != curTime:
|
|
|
|
|
# читаем переменные из файла
|
|
|
|
|
self.prevDictIni = loadVarsIni(fileConfig)
|
|
|
|
|
self.prevDictIni = loadVarsIni(self.fileConfigIni)
|
|
|
|
|
self.currDictIni.update(self.prevDictIni)
|
|
|
|
|
self.timeIni = getTimeFile(fileConfig)
|
|
|
|
|
self.timeIni = getTimeFile(self.fileConfigIni)
|
|
|
|
|
# Значение локальной переменной
|
|
|
|
|
valueLocVar = terms[1]
|
|
|
|
|
self.currDictIni[nameLocVar] = valueLocVar
|
|
|
|
@ -3031,19 +3026,19 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
resS = self._reFunc.search(textProfileTmp)
|
|
|
|
|
else:
|
|
|
|
|
resS = False
|
|
|
|
|
pathConfig = os.path.join(self.homeDir,".calculate","ini.env")
|
|
|
|
|
if self.prevDictIni != self.currDictIni or\
|
|
|
|
|
(self.timeIni!=-1 and getTimeFile(pathConfig)!= self.timeIni):
|
|
|
|
|
(self.timeIni!=-1 and\
|
|
|
|
|
getTimeFile(self.fileConfigIni)!= self.timeIni):
|
|
|
|
|
# Записываем переменные в конфигурационный файл
|
|
|
|
|
# Очистка файла в случае его ошибочного чтения
|
|
|
|
|
if not self.prevDictIni and os.path.exists(pathConfig):
|
|
|
|
|
FD = open(pathConfig, "r+")
|
|
|
|
|
if not self.prevDictIni and os.path.exists(self.fileConfigIni):
|
|
|
|
|
FD = open(self.fileConfigIni, "r+")
|
|
|
|
|
FD.truncate(0)
|
|
|
|
|
FD.seek(0)
|
|
|
|
|
FD.close()
|
|
|
|
|
# Запись переменных
|
|
|
|
|
# Создание объекта парсера
|
|
|
|
|
config = cl_base.iniParser(pathConfig)
|
|
|
|
|
config = cl_base.iniParser(self.fileConfigIni)
|
|
|
|
|
# секции будущего конфигурационного файла
|
|
|
|
|
sects = list(set(map(lambda x: x.split(".")[0],\
|
|
|
|
|
self.currDictIni.keys())))
|
|
|
|
@ -3059,15 +3054,19 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
if dictVar:
|
|
|
|
|
# Запись переменных в секцию
|
|
|
|
|
config.setVar(sect, dictVar)
|
|
|
|
|
if os.path.exists(pathConfig):
|
|
|
|
|
fd = os.open(pathConfig, os.O_RDONLY)
|
|
|
|
|
if os.path.exists(self.fileConfigIni):
|
|
|
|
|
fd = os.open(self.fileConfigIni, os.O_RDONLY)
|
|
|
|
|
fst = os.fstat(fd)
|
|
|
|
|
uid = fst.st_uid
|
|
|
|
|
gid = fst.st_gid
|
|
|
|
|
os.close(fd)
|
|
|
|
|
if self.uid!=uid or self.gid!=gid:
|
|
|
|
|
os.chown(pathConfig, int(self.uid), int(self.gid))
|
|
|
|
|
self.timeIni = getTimeFile(pathConfig)
|
|
|
|
|
os.chown(self.fileConfigIni, int(self.uid), int(self.gid))
|
|
|
|
|
# читаем переменные из файла
|
|
|
|
|
self.prevDictIni = loadVarsIni(self.fileConfigIni)
|
|
|
|
|
self.currDictIni.update(self.prevDictIni)
|
|
|
|
|
self.timeConfigsIni[self.fileConfigIni] = float(time.time())
|
|
|
|
|
self.timeIni = getTimeFile(self.fileConfigIni)
|
|
|
|
|
return textProfileTmp
|
|
|
|
|
|
|
|
|
|
def applyTermsProfile(self, textProfile, nameProfile, nameSystemFile=False):
|
|
|
|
@ -3297,6 +3296,8 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
self.prevDictIni = {}
|
|
|
|
|
# Текущий словарь переменных для ini()
|
|
|
|
|
self.currDictIni = {}
|
|
|
|
|
# Словарь времен модификации env файлов
|
|
|
|
|
self.timeConfigsIni = {}
|
|
|
|
|
if self._servDir:
|
|
|
|
|
tmpDirsProfiles = []
|
|
|
|
|
for dirP in dirsProfiles:
|
|
|
|
@ -3360,6 +3361,9 @@ class profile(_file, _terms, xmlShare, processingTemplates):
|
|
|
|
|
profTitle = '"' + "/".join(listProfTitle) + '"'
|
|
|
|
|
# Записываем в переменную обрабатываемый файл
|
|
|
|
|
self.objVar.Set("cl_pass_file",oldFile)
|
|
|
|
|
# Пишем время модификации *.env файлов
|
|
|
|
|
if oldFile.endswith(".env"):
|
|
|
|
|
self.timeConfigsIni[oldFile] = float(time.time())
|
|
|
|
|
filesApl = self.join(path, oldFile,
|
|
|
|
|
(self.programVersion,profTitle))
|
|
|
|
|
if filesApl:
|
|
|
|
|