diff --git a/connect.py b/connect.py index 7aee8ea83..64a3593f7 100755 --- a/connect.py +++ b/connect.py @@ -438,8 +438,10 @@ class Nav(object): self.user = user self.search_result = None self.user_perm = get_group_user_perm(self.user) - self.perm_assets = tuple(self.user_perm.get('asset', [])) + self.perm_assets = sorted(self.user_perm.get('asset', []).keys(), + key=lambda x: [int(num) for num in x.ip.split('.') if num.isdigit()]) self.perm_asset_groups = self.user_perm.get('asset_group', []) + print self.perm_assets @staticmethod def print_nav(): @@ -494,8 +496,6 @@ class Nav(object): # 如果没有输入就展现所有 self.search_result = self.perm_assets - self.search_result = list(set(self.search_result)) - def print_search_result(self): color_print('[%-3s] %-12s %-15s %-5s %-10s %s' % ('ID', '主机名', 'IP', '端口', '系统用户', '备注'), 'title') if hasattr(self.search_result, '__iter__'):