def __call__(self, *args): argv = self.arguments() raise EArgument("mpxadmin user: Requires a sub-command.\n" " 'mpxadmin user --help' for more " " information.") return
def log_remove(self, command): name = self._get_log_name() if (not self._force_delete and name == 'msglog'): raise EArgument('Must force delete to remove msglog.') log = self._get_log_instance(name) log.destroy()
def __call__(self, *args): argv = self.arguments() if len(argv) != 0: raise EArgument( "mpxadmin list: No arguments are supported.\n" " 'mpxadmin user list --help' for more " " information.") passwd_db = _manager.PasswdFile() passwd_db.load() group_db = _manager.GroupFile() group_db.load() users = [] for user in passwd_db: if user.user_type() in self._types: users.append(user) def _cmp_by_name(u1, u2): return cmp(u1.user(), u2.user()) users.sort(_cmp_by_name) if self._long_output: for user in users: self.put_stdout_msg( ("%(user)s: %(uid)s %(gid)s %(type)s\n") % { 'user': user.user(), 'uid': "uid=%d," % user.uid(), 'gid': "gid=%d," % user.gid(), 'type': "type=%s" % user.user_type() }) groups = user.groups(group_db) text = "" if groups: g = groups.pop(0) text = g.group() for g in groups: text = "%s,%s" % (text, g.group()) self.put_stdout_msg(("%(tab)-4s %(groups)s\n") % { 'tab': "", 'groups': "groups=%s" % text }) self.put_stdout_msg(("%(tab)-4s %(dir)s\n") % { 'tab': "", 'dir': "directory=%s" % user.directory() }) self.put_stdout_msg(("%(tab)-4s %(shell)s\n") % { 'tab': "", 'shell': "shell=%s" % user.shell() }) self.put_stdout_msg("\n") else: if self._one: for user in users: self.put_stdout_msg("%s\n", user.user()) else: columns = 4 rows = (len(users) + columns - 1) / columns for row in range(0, rows): line = "" for column in range(0, columns): index = (row * columns) + column if index >= len(users): break line += "%-18s" % users[index].user() self.put_stdout_msg("%s\n", line) return