Модифицирование прогресс бара для calculate-client

git-svn-id: http://svn.calculate.ru/calculate2/calculate-client/trunk@1078 c91db197-33c1-4113-bf15-f8a5c547ca64
develop
mhiretskiy 15 years ago
parent 18d9886dd2
commit 3864418e73

@ -279,11 +279,27 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
'helpChapter':_("Common options"), 'helpChapter':_("Common options"),
'help':_("display this help and exit") 'help':_("display this help and exit")
}, },
{'shortOption':"h",
'longOption':"help",
'helpChapter':_("Common options"),
'help':_("display this help and exit")
},
{'progAccess':(0,), {'progAccess':(0,),
'shortOption':"r", 'shortOption':"r",
'helpChapter':_("Common options"), 'helpChapter':_("Common options"),
'help':_("Removes the settings for connecting to a domain") 'help':_("Removes the settings for connecting to a domain")
}, },
{'progAccess':(2,),
'longOption':'progress',
'helpChapter':_("Common options"),
'help':_("Show progress bar for kde startup (works only with options \
--login)")
},
{'progAccess':(1,),
'longOption':'progress',
'helpChapter':_("Common options"),
'help':_("Show progress bar for kde startup")
},
{'progAccess':(0,1,2), {'progAccess':(0,1,2),
'longOption':"vars", 'longOption':"vars",
'optVal':_("TYPE_VAR"), 'optVal':_("TYPE_VAR"),
@ -552,14 +568,17 @@ conjunction with the 'login' or 'logout'")
self.printERROR(_("Path %s exists") %userDir) self.printERROR(_("Path %s exists") %userDir)
return False return False
def applyProfilesFromUser(self): def applyProfilesFromUser(self,progress=False):
"""Применяем профили для пользователя""" """Применяем профили для пользователя"""
# Cоздаем объект профиль # Cоздаем объект профиль
#clProf = cl_profile.profile(self.clVars) if progress:
clProf = ProgressProfile(self.clVars) clProf = ProgressProfile(self.clVars)
else:
clProf = cl_profile.profile(self.clVars)
# Объединяем профили # Объединяем профили
dirsFiles = clProf.applyProfiles() dirsFiles = clProf.applyProfiles()
clProf.progress.close() if progress:
clProf.progress.close()
if clProf.getError(): if clProf.getError():
self.printERROR(clProf.getError()) self.printERROR(clProf.getError())
return False return False
@ -661,7 +680,7 @@ conjunction with the 'login' or 'logout'")
alwProfilePath.append(prPath) alwProfilePath.append(prPath)
return alwProfilePath return alwProfilePath
def createHome(self, userName, applyAlways=False): def createHome(self, userName, applyAlways=False, progress=False):
"""Создание пользовательской директории с настройками для kde4""" """Создание пользовательской директории с настройками для kde4"""
# Имя пользователя # Имя пользователя
self.userName = userName self.userName = userName
@ -721,7 +740,7 @@ conjunction with the 'login' or 'logout'")
self.clVars.Set('ur_mail',mail) self.clVars.Set('ur_mail',mail)
self.clVars.Set('ur_group',group) self.clVars.Set('ur_group',group)
# Применяем профили для пользователя # Применяем профили для пользователя
dirsAndFiles = self.applyProfilesFromUser() dirsAndFiles = self.applyProfilesFromUser(progress)
if not dirsAndFiles: if not dirsAndFiles:
# Отмонтируем пользовательские ресурсы в случае ошибки # Отмонтируем пользовательские ресурсы в случае ошибки
self.errorAndUnmountUserRes = True self.errorAndUnmountUserRes = True
@ -1008,7 +1027,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
return False return False
return True return True
def umountUserRes(self, userName): def umountUserRes(self, userName,progress=False):
"""Отмонтирование пользовательских ресурсов и синхронизация настроек""" """Отмонтирование пользовательских ресурсов и синхронизация настроек"""
# Имя пользователя # Имя пользователя
self.userName = userName self.userName = userName
@ -1062,7 +1081,13 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
pathRemote.append((os.path.join(homeDir,"FTP"), "ftp")) pathRemote.append((os.path.join(homeDir,"FTP"), "ftp"))
# Удаленный ресурс share # Удаленный ресурс share
pathRemote.append((os.path.join(homeDir,"Disks"), "share")) pathRemote.append((os.path.join(homeDir,"Disks"), "share"))
self.moveHomeDir(homeDir) if os.path.exists(homeDir):
self.moveHomeDir(homeDir)
else:
# Отмонтируем пользовательские ресурсы в случае ошибки
self.errorAndUnmountUserRes = True
self.printERROR(_("Directory %s not found") % homeDir)
return False
# Синхронизируем настройки # Синхронизируем настройки
pathUnix = "" pathUnix = ""
for path, res in pathRemote: for path, res in pathRemote:
@ -1137,7 +1162,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
return True return True
def umountUserResNoSync(self, userName, printError=True, def umountUserResNoSync(self, userName, printError=True,
printSuccess=True, isXsession=True, killRsync=False): printSuccess=True, isXsession=True, killRsync=False,
progress=False):
"""Отмонтирование пользовательских ресурсов """Отмонтирование пользовательских ресурсов
без синхронизации настроек""" без синхронизации настроек"""
@ -1283,7 +1309,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
os.rmdir(rmDir) os.rmdir(rmDir)
return True return True
def mountUserRes(self, userName, sync=True): def mountUserRes(self, userName, sync=True, progress=False):
"""Монтирование пользовательских ресурсов и синхронизация настроек""" """Монтирование пользовательских ресурсов и синхронизация настроек"""
# Имя пользователя # Имя пользователя
self.userName = userName self.userName = userName
@ -1425,7 +1451,9 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
# Если на текущем сервере в ресурсе unix есть файлы # Если на текущем сервере в ресурсе unix есть файлы
# то синхронируем настройки # то синхронируем настройки
if os.listdir(defaultPath): if os.listdir(defaultPath):
if not self.syncUser(userName, homeDir, "login", uid, gid): if not self.syncUser(userName, homeDir, "login", uid, gid,\
progress=progress,
host=self.clVars.Get('cl_remote_host')):
# Отмонтируем пользовательские ресурсы в случае ошибки # Отмонтируем пользовательские ресурсы в случае ошибки
self.errorAndUnmountUserRes = True self.errorAndUnmountUserRes = True
return False return False
@ -1496,7 +1524,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
return False return False
# Синхронизируем настройки пользователя # Синхронизируем настройки пользователя
if not (pathReplRun and mountServer == "default"): if not (pathReplRun and mountServer == "default"):
if not self.syncUser(userName, homeDir, "login", uid, gid): if not self.syncUser(userName, homeDir, "login", uid, gid,\
progress=progress,host=prevHost):
if pathReplRun and mountServer == "remote": if pathReplRun and mountServer == "remote":
replErrorSync = True replErrorSync = True
else: else:
@ -1631,7 +1660,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
FD.close() FD.close()
return True return True
def syncUser(self, userName, userHome, sync, uid, gid): def syncUser(self, userName, userHome, sync, uid, gid, progress=False,\
host="default"):
"""Синхронизация пользовательских настроек""" """Синхронизация пользовательских настроек"""
home = os.path.split(userHome)[0] home = os.path.split(userHome)[0]
homeProfile = os.path.join(home,"." + userName) homeProfile = os.path.join(home,"." + userName)
@ -1681,7 +1711,9 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
%str(sync)) %str(sync))
return False return False
if execStr: if execStr:
rsync = RsyncProgressBar("Syncronizing user settings...",execStr) rsync = RsyncProgressBar(\
"Syncronizing user settings with %s server..." %
host,execStr)
configFileName = os.path.join(homeProfile,self.configFile) configFileName = os.path.join(homeProfile,self.configFile)
if sync == "login": if sync == "login":
# получить переменную files из секции Rsync файла # получить переменную files из секции Rsync файла
@ -1698,7 +1730,10 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
except: except:
numfiles = 1 numfiles = 1
rsync.maximum = numfiles rsync.maximum = numfiles
rsync.run() if progress:
rsync.run()
else:
rsync.runsilent()
if sync == "logout": if sync == "logout":
rsync.runsilent() rsync.runsilent()
# получаем uid и gid пользователя # получаем uid и gid пользователя

@ -51,15 +51,18 @@ if __name__ == "__main__":
{}) {})
ldapObj = newClass("cl-createhome") ldapObj = newClass("cl-createhome")
userName = optObj.params['user'].strip() userName = optObj.params['user'].strip()
show_progress = optObj.opt.has_key('progress')
if optObj.opt.has_key('f'): if optObj.opt.has_key('f'):
if not ldapObj.createHome(userName,True): if not ldapObj.createHome(userName,True,progress=show_progress):
flagError = True flagError = True
else: else:
if not ldapObj.createHome(userName): if not ldapObj.createHome(userName,progress=show_progress):
flagError = True flagError = True
else: else:
ldapObj.printERROR(_("Not found 'user' in command line")) if not optObj.flagHelp:
ldapObj.printERROR(_('Try "cl-createhome --help" for more information')) ldapObj.printERROR(_("Not found 'user' in command line"))
ldapObj.printERROR(\
_('Try "cl-createhome --help" for more information'))
flagError = True flagError = True
if flagError: if flagError:
sys.exit(1) sys.exit(1)

@ -52,19 +52,22 @@ if __name__ == "__main__":
cl_client.cl_client,object), cl_client.cl_client,object),
{}) {})
ldapObj = newClass("cl-sync") ldapObj = newClass("cl-sync")
if optObj.opt.has_key('login') and optObj.opt.has_key('nosync'): progress = optObj.opt.has_key('progress')
if optObj.opt.has_key('login') and optObj.opt.has_key('nosync') \
and not progress:
userName = optObj.params['user'] userName = optObj.params['user']
if not ldapObj.mountUserRes(userName,False): if not ldapObj.mountUserRes(userName,False):
flagError = True flagError = True
elif optObj.opt.has_key('login'): elif optObj.opt.has_key('login'):
userName = optObj.params['user'] userName = optObj.params['user']
if not ldapObj.mountUserRes(userName): if not ldapObj.mountUserRes(userName,progress=progress):
flagError = True flagError = True
elif optObj.opt.has_key('logout') and optObj.opt.has_key('nosync'): elif optObj.opt.has_key('logout') and optObj.opt.has_key('nosync')\
and not progress:
userName = optObj.params['user'] userName = optObj.params['user']
if not ldapObj.umountUserResNoSync(userName): if not ldapObj.umountUserResNoSync(userName):
flagError = True flagError = True
elif optObj.opt.has_key('logout'): elif optObj.opt.has_key('logout') and not progress:
userName = optObj.params['user'] userName = optObj.params['user']
if not ldapObj.umountUserRes(userName): if not ldapObj.umountUserRes(userName):
flagError = True flagError = True

Loading…
Cancel
Save