|
|
|
@ -116,7 +116,7 @@ org.kde.kdialog.ProgressDialog'
|
|
|
|
|
def close(self):
|
|
|
|
|
'''Закрыть прогресс'''
|
|
|
|
|
self.shutdownDialog()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProgressProfile(cl_profile.profile):
|
|
|
|
|
def __init__(self, vars):
|
|
|
|
|
cl_profile.profile.__init__(self,vars)
|
|
|
|
@ -1348,28 +1348,38 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
textLine = self.execProg(mountStr)
|
|
|
|
|
return textLine
|
|
|
|
|
|
|
|
|
|
def removeDir(self, rmDir):
|
|
|
|
|
"""Рекурсивное удаление директории"""
|
|
|
|
|
if not os.path.exists(rmDir):
|
|
|
|
|
self.printERROR(_("Not found remove dir %s") %rmDir)
|
|
|
|
|
return False
|
|
|
|
|
fileObj = cl_profile._file()
|
|
|
|
|
# Сканируем директорию
|
|
|
|
|
scanObjs = fileObj.scanDirs([rmDir])
|
|
|
|
|
for fileRm in scanObjs[0].files:
|
|
|
|
|
# Удаляем файлы
|
|
|
|
|
os.remove(fileRm)
|
|
|
|
|
def removeDir(self, rmDirOrScanObjs):
|
|
|
|
|
"""Рекурсивное удаление директории
|
|
|
|
|
|
|
|
|
|
входной параметр директория или результат сканирования файлов (объект)
|
|
|
|
|
"""
|
|
|
|
|
rmDir = False
|
|
|
|
|
if type(rmDirOrScanObjs) == types.StringType:
|
|
|
|
|
rmDir = rmDirOrScanObjs
|
|
|
|
|
if not os.path.exists(rmDir):
|
|
|
|
|
self.printERROR(_("Not found remove dir %s") %rmDir)
|
|
|
|
|
return False
|
|
|
|
|
fileObj = cl_profile._file()
|
|
|
|
|
# Сканируем директорию
|
|
|
|
|
scanObjs = fileObj.scanDirs([rmDir])
|
|
|
|
|
else:
|
|
|
|
|
scanObjs = rmDirOrScanObjs
|
|
|
|
|
for socketRm in scanObjs[0].sockets:
|
|
|
|
|
# Удаляем сокеты
|
|
|
|
|
os.remove(socketRm)
|
|
|
|
|
if os.path.exists(socketRm):
|
|
|
|
|
os.remove(socketRm)
|
|
|
|
|
for linkRm in scanObjs[0].links:
|
|
|
|
|
# Удаляем ссылки
|
|
|
|
|
os.unlink(linkRm[1])
|
|
|
|
|
for fileRm in scanObjs[0].files:
|
|
|
|
|
# Удаляем файлы
|
|
|
|
|
os.remove(fileRm)
|
|
|
|
|
scanObjs[0].dirs.sort(lambda x, y: cmp(len(y), len(x)))
|
|
|
|
|
for dirRm in scanObjs[0].dirs:
|
|
|
|
|
# Удаляем директории
|
|
|
|
|
os.rmdir(dirRm)
|
|
|
|
|
os.rmdir(rmDir)
|
|
|
|
|
if rmDir:
|
|
|
|
|
os.rmdir(rmDir)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def isCorrectProfileOnLocalServer(self,userName):
|
|
|
|
@ -1516,6 +1526,9 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
prevHost = ""
|
|
|
|
|
# Монтирование по умолчанию (default - cвой сервер, remote - чужой)
|
|
|
|
|
mountServer = ""
|
|
|
|
|
# Переносим настройки пользователя в новую директорию
|
|
|
|
|
# .CLD
|
|
|
|
|
self.upgradeProfileClient(userName, homeDir)
|
|
|
|
|
if pathReplRun:
|
|
|
|
|
searchPrevHost = self.searchPrevHost(userName)
|
|
|
|
|
if searchPrevHost and searchPrevHost[0][0][1].has_key('host'):
|
|
|
|
@ -1523,7 +1536,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
# Монтируем ресурс unix текущего сервера
|
|
|
|
|
mountServer = "default"
|
|
|
|
|
textLine = self.mountSleepRes(userName,userPwd,uid,gid,
|
|
|
|
|
"unix",defaultPath)
|
|
|
|
|
"unix",defaultPath)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not mount Samba resource [%s]")\
|
|
|
|
|
%"unix" + " ...")
|
|
|
|
@ -1747,11 +1760,96 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
FD.close()
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def copyProfileDir(self, destDir, srcDir):
|
|
|
|
|
"""Копируем директорию в другое место
|
|
|
|
|
|
|
|
|
|
При копировании сохраняются владелец, группа, права
|
|
|
|
|
"""
|
|
|
|
|
if os.path.exists(destDir) and not os.listdir(destDir):
|
|
|
|
|
os.rmdir(destDir)
|
|
|
|
|
# Файловый объект
|
|
|
|
|
fileObj = cl_profile._file()
|
|
|
|
|
# Сканируем директорию
|
|
|
|
|
scanObjs = fileObj.scanDirs([srcDir])
|
|
|
|
|
if not os.path.exists(destDir):
|
|
|
|
|
# Создаем директорию
|
|
|
|
|
os.makedirs(destDir)
|
|
|
|
|
if not scanObjs:
|
|
|
|
|
return True
|
|
|
|
|
for dirSrc in scanObjs[0].dirs:
|
|
|
|
|
#создаем в домашней директории директории из srcDir
|
|
|
|
|
dirName = destDir + dirSrc.split(srcDir)[1]
|
|
|
|
|
os.mkdir(dirName)
|
|
|
|
|
mode,uid,gid = fileObj.getModeFile(dirSrc)
|
|
|
|
|
os.chown(dirName, uid,gid)
|
|
|
|
|
os.chmod(destDir, mode)
|
|
|
|
|
for fileCopy in scanObjs[0].files:
|
|
|
|
|
oldFile = destDir + fileCopy.split(srcDir)[1]
|
|
|
|
|
#копируем файлы
|
|
|
|
|
fileObj.openFiles(fileCopy, oldFile)
|
|
|
|
|
fileObj.saveOldFile()
|
|
|
|
|
fileObj.oldProfile = False
|
|
|
|
|
fileObj.closeFiles()
|
|
|
|
|
os.chown(oldFile, fileObj._uid, fileObj._gid)
|
|
|
|
|
os.chmod(oldFile, fileObj._mode)
|
|
|
|
|
for linkCreate in scanObjs[0].links:
|
|
|
|
|
#копируем ссылки
|
|
|
|
|
dst = destDir + linkCreate[1].split(srcDir)[1]
|
|
|
|
|
srcDestList = linkCreate[0].split(srcDir)
|
|
|
|
|
if len(srcDestList)>1:
|
|
|
|
|
src = destDir + srcDestList[1]
|
|
|
|
|
else:
|
|
|
|
|
src = linkCreate[0]
|
|
|
|
|
os.symlink(src,dst)
|
|
|
|
|
if os.path.exists(dst):
|
|
|
|
|
mode,uid,gid = fileObj.getModeFile(dst)
|
|
|
|
|
#Изменение прав на ссылки
|
|
|
|
|
os.lchown(dst, uid, gid)
|
|
|
|
|
# Удаляем сокеты
|
|
|
|
|
for rmSocket in scanObjs[0].sockets:
|
|
|
|
|
os.remove(rmSocket)
|
|
|
|
|
mode,uid,gid = fileObj.getModeFile(srcDir)
|
|
|
|
|
os.chmod(destDir, mode)
|
|
|
|
|
os.chown(destDir, uid,gid)
|
|
|
|
|
self.removeDir(scanObjs)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def upgradeProfileClient(self, userName, userHome):
|
|
|
|
|
"""Переносит данные клиента в директорию .CLD
|
|
|
|
|
|
|
|
|
|
Перед вызовом этого метода обязательно должен быть определен атрибут
|
|
|
|
|
объекта self.clVars - объект переменных
|
|
|
|
|
"""
|
|
|
|
|
# Директория хранения старых профилей
|
|
|
|
|
home = os.path.split(userHome)[0]
|
|
|
|
|
pathOldProfile = os.path.join(home, "." + userName)
|
|
|
|
|
if os.path.exists(pathOldProfile):
|
|
|
|
|
osLinuxShort = self.clVars.Get("os_linux_shortname")
|
|
|
|
|
skipDirs = [".CLD", ".CLDX"]
|
|
|
|
|
# Если есть скрытые файлы кроме skipDir
|
|
|
|
|
# а так-же нет файлов skipDir - делаем апгрейд
|
|
|
|
|
if filter(lambda x: x[0]==".",
|
|
|
|
|
list(set(os.listdir(pathOldProfile))-set(skipDirs))) and\
|
|
|
|
|
len(filter(lambda x: not os.path.exists(os.path.join(pathOldProfile,x)),
|
|
|
|
|
skipDirs))==2:
|
|
|
|
|
# Копируем профиль в новое место
|
|
|
|
|
patchNewProfile = os.path.join(pathOldProfile,".CLD")
|
|
|
|
|
self.copyProfileDir(patchNewProfile, pathOldProfile)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def syncUser(self, userName, userHome, sync, uid, gid, progress=False,\
|
|
|
|
|
host="default"):
|
|
|
|
|
"""Синхронизация пользовательских настроек"""
|
|
|
|
|
"""Синхронизация пользовательских настроек
|
|
|
|
|
|
|
|
|
|
Перед вызовом этого метода обязательно должен быть определен атрибут
|
|
|
|
|
объекта self.clVars - объект переменных
|
|
|
|
|
"""
|
|
|
|
|
home = os.path.split(userHome)[0]
|
|
|
|
|
homeProfile = os.path.join(home,"." + userName)
|
|
|
|
|
osLinuxShort = self.clVars.Get("os_linux_shortname")
|
|
|
|
|
homeProfile = os.path.join(home, "." + userName, osLinuxShort)
|
|
|
|
|
if not os.path.exists(homeProfile):
|
|
|
|
|
homeProfile = os.path.join(home, "." + userName,
|
|
|
|
|
"." + osLinuxShort)
|
|
|
|
|
flagError = False
|
|
|
|
|
execStr = ""
|
|
|
|
|
if sync == "login":
|
|
|
|
|