diff --git a/pym/cl_client.py b/pym/cl_client.py index 5606b43..c8d4940 100644 --- a/pym/cl_client.py +++ b/pym/cl_client.py @@ -37,6 +37,7 @@ from cl_ldap import ldapUser from client.progressbar import ProgressBar from cl_utils import runOsCommand, getpathenv, getModeFile, removeDir, isMount from _cl_keys import getKey, clearKey +from convertenv import convertEnv lang().setLanguage(sys.modules[__name__]) @@ -206,7 +207,7 @@ class ldapData(ldapUser): return resSearch return False - def getNameRemoteServer(self,userName, osLinuxShort): + def getNameRemoteServer(self,userName, osLinuxShort, curHost): """Если профиль на удаленном сервере, то выдать DNS имя этого сервера """ searchPrevHost = self.searchPrevHost(userName, osLinuxShort) @@ -216,7 +217,7 @@ class ldapData(ldapUser): prevHost = None # если местоположение актуального профиля найти не удалось # или его местоположение не на локальном сервере - if not prevHost or prevHost == osLinuxShort: + if not prevHost or prevHost == curHost: return False else: return prevHost @@ -263,6 +264,9 @@ class client(share): # словарь опций сервисов из /var/calculate/remote/server.env optionsInfo = {} + # объект конвертирования из старого remote env файла + convObj = None + def removeVars(self): """Удаление переменных шаблонов @@ -510,7 +514,7 @@ class client(share): # Создаем директорию для конфигурационных файлов if not os.path.exists(pathConfig): self.createUserDir(uid, gid, pathConfig, mode=False) - configFileName = os.path.join(pathConfig, self.configFileDesktop) + configFileName = os.path.join(homeTemplate, self.configFileDesktop) if sync == "login": # получить переменную files из секции Rsync файла # .calculate.ini @@ -842,7 +846,8 @@ class client(share): if replOn: osLinuxShort = self.clVars.Get("os_linux_shortname") remoteServer = self.ldapDataObj.getNameRemoteServer(userName, - osLinuxShort) + osLinuxShort, + domain) # Получаем монтируемые директории names, dictRes = self.getUserMountResources(userName, homeDir, remoteServer) @@ -1277,7 +1282,7 @@ class client(share): userLdapInfo = self.ldapDataObj.getUserLdapInfo(userName) if userLdapInfo: uid = int(userLdapInfo['uid']) - gid = int(userLdapInfo['uid']) + gid = int(userLdapInfo['gid']) homeDir = userLdapInfo['home'] else: self.printERROR(_("Can not found user %s in LDAP")%userName) @@ -1541,6 +1546,16 @@ class client(share): def getInfoService(self, service, option, envFile=False): """Получить параметр сервиса из env""" + if not envFile: + if self.convObj == None: + # файл /var/calculate/remote/server.env + envFile = self.clVars.Get("cl_env_server_path") + if os.access(envFile, os.R_OK): + self.convObj = False + elif os.access("/var/calculate/remote/calculate.env", os.R_OK): + self.convObj = convertEnv() + if self.convObj: + return self.convObj.getVar(service, option) if not self.optionsInfo: if not envFile: # файл /var/calculate/remote/server.env diff --git a/pym/cl_client_cmd.py b/pym/cl_client_cmd.py index 7081515..0a3053a 100644 --- a/pym/cl_client_cmd.py +++ b/pym/cl_client_cmd.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from cl_client import client, __app__, __version__ -from cl_opt import opt, TitledHelpFormatter +from cl_opt import opt import sys from cl_share_cmd import share_cmd @@ -52,7 +52,6 @@ class client_cmd(share_cmd): comment_examples=COMMENT_EXAMPLES, description=DESCRIPTION, option_list=CMD_OPTIONS + opt.variable_control+opt.color_control, - formatter=TitledHelpFormatter(), check_values=self.checkOpts) # Создаем объект логики self.logicObj = client() diff --git a/pym/cl_install_cmd.py b/pym/cl_install_cmd.py index 16dd86b..174f63b 100644 --- a/pym/cl_install_cmd.py +++ b/pym/cl_install_cmd.py @@ -15,7 +15,7 @@ # limitations under the License. from cl_client import client, __app__, __version__ -from cl_opt import opt, TitledHelpFormatter +from cl_opt import opt import sys from cl_share_cmd import share_cmd @@ -38,7 +38,6 @@ class install_cmd(share_cmd): usage=USAGE, description=DESCRIPTION, option_list=opt.variable_control+opt.color_control, - formatter=TitledHelpFormatter(), check_values=self.checkOpts) # Создаем объект логики self.logicObj = client() diff --git a/pym/cl_sync.py b/pym/cl_sync_cmd.py similarity index 98% rename from pym/cl_sync.py rename to pym/cl_sync_cmd.py index 2dca863..227707e 100644 --- a/pym/cl_sync.py +++ b/pym/cl_sync_cmd.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from cl_client import client, __app__, __version__ -from cl_opt import opt, TitledHelpFormatter +from cl_opt import opt import sys from cl_share_cmd import share_cmd @@ -47,7 +47,7 @@ resource")}, 'help':_("not synchronize the user preferences, is used \ in conjunction with the 'login' or 'logout'")}] -class sync(share_cmd): +class sync_cmd(share_cmd): def __init__(self): # Объект опций командной строки self.optobj = opt(\ @@ -58,7 +58,6 @@ class sync(share_cmd): comment_examples=COMMENT_EXAMPLES, description=DESCRIPTION, option_list=CMD_OPTIONS + opt.variable_control+opt.color_control, - formatter=TitledHelpFormatter(), check_values=self.checkOpts) # Создаем объект логики self.logicObj = client() diff --git a/pym/cl_uninstall_cmd.py b/pym/cl_uninstall_cmd.py index 078221b..decd311 100644 --- a/pym/cl_uninstall_cmd.py +++ b/pym/cl_uninstall_cmd.py @@ -15,7 +15,7 @@ # limitations under the License. from cl_client import client, __app__, __version__ -from cl_opt import opt, TitledHelpFormatter +from cl_opt import opt import sys from cl_share_cmd import share_cmd @@ -38,7 +38,6 @@ class uninstall_cmd(share_cmd): usage=USAGE, description=DESCRIPTION, option_list=opt.variable_control+opt.color_control, - formatter=TitledHelpFormatter(), check_values=self.checkOpts) # Создаем объект логики self.logicObj = client() diff --git a/scripts/cl-client-2.2 b/scripts/cl-client similarity index 100% rename from scripts/cl-client-2.2 rename to scripts/cl-client diff --git a/scripts/cl-sync-2.2 b/scripts/cl-sync similarity index 97% rename from scripts/cl-sync-2.2 rename to scripts/cl-sync index bdf8c41..9cfc9c5 100644 --- a/scripts/cl-sync-2.2 +++ b/scripts/cl-sync @@ -21,7 +21,7 @@ sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym')) sys.path.insert(0,\ os.path.abspath('/usr/lib/calculate-2.2/calculate-client/pym')) -from cl_sync import sync +from cl_sync_cmd import sync_cmd from cl_lang import lang tr = lang() @@ -29,7 +29,7 @@ tr.setGlobalDomain('cl_desktop') tr.setLanguage(sys.modules[__name__]) if __name__ == "__main__": - obj = sync() + obj = sync_cmd() ret = obj.optobj.parse_args() if ret is False: sys.exit(1) diff --git a/setup.py b/setup.py index 46c2ead..5473e22 100755 --- a/setup.py +++ b/setup.py @@ -141,8 +141,8 @@ setup( package_dir = {'calculate-client': "."}, packages = ['calculate-client.pym'], data_files = data_files, - scripts=["./scripts/cl-sync-2.2", - "./scripts/cl-client-2.2", + scripts=["./scripts/cl-sync", + "./scripts/cl-client", "./scripts/install", "./scripts/uninstall"], ext_modules = [Extension('calculate-client.pym._cl_keys',