Use hostname infor instead of users list
authorPeng Li <seudut@gmail.com>
Sat, 28 Jul 2018 12:56:39 +0000 (20:56 +0800)
committerPeng Li <seudut@gmail.com>
Sat, 28 Jul 2018 12:56:39 +0000 (20:56 +0800)
board/suanzi-support

index 3795d83..f55b41a 100755 (executable)
@@ -39,11 +39,8 @@ def get_mac_str():
     m = re.sub('^0x|L$', '', mac)
     return '{:0>12}'.format(m)
 
-
-def get_users():
-    out = check_output("/bin/ls /home", shell=True).strip()
-    out = out.strip().split()
-    return " ".join(out)
+def get_hostname():
+    return check_output("/bin/hostname", shell=True).strip();
 
 def exec_ssh(port):
     if port == None:
@@ -71,7 +68,7 @@ def on_message(client, userdata, msg):
             else:
                 raise Exception ('run ssh failed')
         if payload['command'] == 'list':
-            response = {'from': userdata['id'], 'type':'response', 'command':payload['command'], 'data': get_users()}
+            response = {'from': userdata['id'], 'type':'response', 'command':payload['command'], 'data': get_hostname()}
             client.publish(payload['from'], str(response))