diff --git a/pym/cl_client.py b/pym/cl_client.py index 440d0a7..d63e354 100644 --- a/pym/cl_client.py +++ b/pym/cl_client.py @@ -279,11 +279,27 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon): 'helpChapter':_("Common options"), 'help':_("display this help and exit") }, + {'shortOption':"h", + 'longOption':"help", + 'helpChapter':_("Common options"), + 'help':_("display this help and exit") + }, {'progAccess':(0,), 'shortOption':"r", 'helpChapter':_("Common options"), '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), 'longOption':"vars", 'optVal':_("TYPE_VAR"), @@ -552,14 +568,17 @@ conjunction with the 'login' or 'logout'") self.printERROR(_("Path %s exists") %userDir) return False - def applyProfilesFromUser(self): + def applyProfilesFromUser(self,progress=False): """Применяем профили для пользователя""" # Cоздаем объект профиль - #clProf = cl_profile.profile(self.clVars) - clProf = ProgressProfile(self.clVars) + if progress: + clProf = ProgressProfile(self.clVars) + else: + clProf = cl_profile.profile(self.clVars) # Объединяем профили dirsFiles = clProf.applyProfiles() - clProf.progress.close() + if progress: + clProf.progress.close() if clProf.getError(): self.printERROR(clProf.getError()) return False @@ -661,7 +680,7 @@ conjunction with the 'login' or 'logout'") alwProfilePath.append(prPath) return alwProfilePath - def createHome(self, userName, applyAlways=False): + def createHome(self, userName, applyAlways=False, progress=False): """Создание пользовательской директории с настройками для kde4""" # Имя пользователя self.userName = userName @@ -721,7 +740,7 @@ conjunction with the 'login' or 'logout'") self.clVars.Set('ur_mail',mail) self.clVars.Set('ur_group',group) # Применяем профили для пользователя - dirsAndFiles = self.applyProfilesFromUser() + dirsAndFiles = self.applyProfilesFromUser(progress) if not dirsAndFiles: # Отмонтируем пользовательские ресурсы в случае ошибки self.errorAndUnmountUserRes = True @@ -1008,7 +1027,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) return False return True - def umountUserRes(self, userName): + def umountUserRes(self, userName,progress=False): """Отмонтирование пользовательских ресурсов и синхронизация настроек""" # Имя пользователя self.userName = userName @@ -1062,7 +1081,13 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) pathRemote.append((os.path.join(homeDir,"FTP"), "ftp")) # Удаленный ресурс 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 = "" for path, res in pathRemote: @@ -1137,7 +1162,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) return 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) return True - def mountUserRes(self, userName, sync=True): + def mountUserRes(self, userName, sync=True, progress=False): """Монтирование пользовательских ресурсов и синхронизация настроек""" # Имя пользователя self.userName = userName @@ -1425,7 +1451,9 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) # Если на текущем сервере в ресурсе unix есть файлы # то синхронируем настройки 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 return False @@ -1496,7 +1524,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) return False # Синхронизируем настройки пользователя 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": replErrorSync = True else: @@ -1631,7 +1660,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) FD.close() 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] homeProfile = os.path.join(home,"." + userName) @@ -1681,7 +1711,9 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) %str(sync)) return False 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) if sync == "login": # получить переменную files из секции Rsync файла @@ -1698,7 +1730,10 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) except: numfiles = 1 rsync.maximum = numfiles - rsync.run() + if progress: + rsync.run() + else: + rsync.runsilent() if sync == "logout": rsync.runsilent() # получаем uid и gid пользователя diff --git a/scripts/cl-createhome b/scripts/cl-createhome index c7245c3..f28d2fc 100644 --- a/scripts/cl-createhome +++ b/scripts/cl-createhome @@ -51,15 +51,18 @@ if __name__ == "__main__": {}) ldapObj = newClass("cl-createhome") userName = optObj.params['user'].strip() + show_progress = optObj.opt.has_key('progress') if optObj.opt.has_key('f'): - if not ldapObj.createHome(userName,True): + if not ldapObj.createHome(userName,True,progress=show_progress): flagError = True else: - if not ldapObj.createHome(userName): + if not ldapObj.createHome(userName,progress=show_progress): flagError = True else: - ldapObj.printERROR(_("Not found 'user' in command line")) - ldapObj.printERROR(_('Try "cl-createhome --help" for more information')) + if not optObj.flagHelp: + ldapObj.printERROR(_("Not found 'user' in command line")) + ldapObj.printERROR(\ + _('Try "cl-createhome --help" for more information')) flagError = True if flagError: sys.exit(1) diff --git a/scripts/cl-sync b/scripts/cl-sync index f4fddc7..a329ee1 100644 --- a/scripts/cl-sync +++ b/scripts/cl-sync @@ -52,19 +52,22 @@ if __name__ == "__main__": cl_client.cl_client,object), {}) 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'] if not ldapObj.mountUserRes(userName,False): flagError = True elif optObj.opt.has_key('login'): userName = optObj.params['user'] - if not ldapObj.mountUserRes(userName): + if not ldapObj.mountUserRes(userName,progress=progress): 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'] if not ldapObj.umountUserResNoSync(userName): flagError = True - elif optObj.opt.has_key('logout'): + elif optObj.opt.has_key('logout') and not progress: userName = optObj.params['user'] if not ldapObj.umountUserRes(userName): flagError = True