Commit ac875d39 authored by ibuler's avatar ibuler

简单修改

parent 3c422402
...@@ -150,8 +150,8 @@ def posix_shell(chan, user, host): ...@@ -150,8 +150,8 @@ def posix_shell(chan, user, host):
log.close() log.close()
def get_host_all(username): def get_user_host(username):
host_all = {} hosts = {}
try: try:
user = User.objects.get(username=username) user = User.objects.get(username=username)
except AttributeError: except AttributeError:
...@@ -159,8 +159,8 @@ def get_host_all(username): ...@@ -159,8 +159,8 @@ def get_host_all(username):
else: else:
perm_all = user.permission_set.all() perm_all = user.permission_set.all()
for perm in perm_all: for perm in perm_all:
host_all[perm.asset.ip] = perm.asset.comment hosts[perm.asset.ip] = perm.asset.comment
return host_all return hosts
def print_prompt(): def print_prompt():
...@@ -175,7 +175,7 @@ def print_prompt(): ...@@ -175,7 +175,7 @@ def print_prompt():
def print_user_host(username): def print_user_host(username):
host_all = get_host_all(username) host_all = get_user_host(username)
for ip, comment in host_all.items(): for ip, comment in host_all.items():
print '%s -- %s' % (ip, comment) print '%s -- %s' % (ip, comment)
...@@ -231,7 +231,7 @@ if __name__ == '__main__': ...@@ -231,7 +231,7 @@ if __name__ == '__main__':
except EOFError: except EOFError:
continue continue
if option in ['P', 'p']: if option in ['P', 'p']:
print_user_host() print_user_host(username)
continue continue
elif option in ['E', 'e']: elif option in ['E', 'e']:
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment