diff --git a/pym/unix/unix.py b/pym/unix/unix.py index 98745cc..41b2684 100644 --- a/pym/unix/unix.py +++ b/pym/unix/unix.py @@ -633,7 +633,15 @@ class Unix(Ldap): """ Преместить домашнюю директорию пользователя """ + if not path.exists(homedir): + self.printWARNING(_("Previous home directory %s not found") + % homedir) + return True try: + self.printSUCCESS( + _("User home directory {homedir} " + "moved to {new_homedir}").format( + homedir=homedir, new_homedir=new_homedir)) dirname = path.dirname(new_homedir) if not path.exists(dirname): os.makedirs(dirname) @@ -735,10 +743,10 @@ class Unix(Ldap): fields=table_fields, onClick='unix_groupmod' if any(table_fields) else None, addAction='unix_groupadd', - records=str(maxi+1)) + records=str(maxi + 1)) if any(body): num_page, count_page = getPagesInterval( - count, offset, maxi+1) + count, offset, maxi + 1) self.printSUCCESS(_('page %d from ') % num_page + str(count_page)) return True @@ -864,10 +872,10 @@ class Unix(Ldap): fields=table_fields, onClick='unix_usermod' if any(table_fields) else None, addAction='unix_useradd', - records=str(maxi+1)) + records=str(maxi + 1)) if any(body): num_page, count_page = getPagesInterval( - count, offset, maxi+1) + count, offset, maxi + 1) self.printSUCCESS(_('page %d from ') % num_page + str(count_page)) return True diff --git a/pym/unix/utils/cl_unix_usermod.py b/pym/unix/utils/cl_unix_usermod.py index e4a3877..28d40f9 100644 --- a/pym/unix/utils/cl_unix_usermod.py +++ b/pym/unix/utils/cl_unix_usermod.py @@ -72,8 +72,6 @@ class ClUnixUsermodAction(Action): 'condition': lambda Get: Get('unix.ur_unix_groups_add') }, {'name': 'move_homedir', - 'message': _("User home directory {unix.ur_unix_home_path_exists} " - "moved to {unix.ur_unix_home_path}"), 'method': 'Unix.move_home_directory(unix.ur_unix_home_path_exists,' 'unix.ur_unix_home_path)', 'condition': lambda Get: Get('unix.ur_unix_home_path_move') == 'on' diff --git a/pym/unix/variables/groups.py b/pym/unix/variables/groups.py index 0558dd5..e8483ee 100644 --- a/pym/unix/variables/groups.py +++ b/pym/unix/variables/groups.py @@ -56,6 +56,8 @@ class VariableUrUnixGroupName(LdapSearchHelper, UnixActionHelper, Variable): raise VariableError(_("You should specify group name")) if not re.match("^[a-zA-Z_]([a-zA-Z0-9_ -]*[a-zA-Z0-9_-])?$", value): raise VariableError(_("Wrong group name")) + if value == "list": + raise VariableError(_("List is using as keyword")) if self.check_name(value): raise VariableError(_("Group name already exists")) @@ -481,3 +483,6 @@ class VariableUrUnixGroupShow(UnixGroupHelper, if value: if not self.search_ldap_group_name(value): raise VariableError(_("%s group not found") % value) + + def raiseWrongChoice(self, name, choiceVal, value, error): + raise VariableError(_("Wrong group name")) diff --git a/pym/unix/variables/users.py b/pym/unix/variables/users.py index 35fbc5a..489b7ee 100644 --- a/pym/unix/variables/users.py +++ b/pym/unix/variables/users.py @@ -58,6 +58,8 @@ class VariableUrUnixLogin(UnixUserHelper, UnixActionHelper, Variable): raise VariableError(_("You should specify login")) if not re.match("^[a-zA-Z_]([a-zA-Z0-9_ -]*[a-zA-Z0-9_-])?$", value): raise VariableError(_("Wrong user login")) + if value == "list": + raise VariableError(_("List is using as keyword")) if self.search_ldap_user_name(value): raise VariableError(_("User %s already exists" % value)) if self.search_system_user_name(value): @@ -183,9 +185,6 @@ class VariableUrUnixHomePathMove(Variable): if path.exists(new_path): raise VariableError( _("New home directory %s exists") % new_path) - if not path.exists(old_path): - raise VariableError( - _("Previous home directory %s not found") % old_path) class VariableClUnixGroupDefault(Variable): @@ -719,3 +718,6 @@ class VariableUrUnixUserShow(UnixUserHelper, UnixActionHelper, Variable): if value: if not self.search_ldap_user_name(value): raise VariableError(_("%s user not found") % value) + + def raiseWrongChoice(self, name, choiceVal, value, error): + raise VariableError(_("Wrong user name"))