X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=suanzi-support;h=367f37963571cbb0cbfebc88aa97976d228bd523;hb=2e0f2852d177cbed7ab450ff45ac6db8ad074b57;hp=8809b0510f9f1249707e6da9526781d400483eda;hpb=37f9e2211af34de067d406fb5a7c85dfba104c3e;p=remote-debug.git diff --git a/suanzi-support b/suanzi-support index 8809b05..367f379 100755 --- a/suanzi-support +++ b/suanzi-support @@ -1,13 +1,8 @@ #!/usr/bin/env python2 -# dependencies: -# 1. pip install paho-mqtt -# 2. apt-get install sshpass -# from subprocess import call, Popen, PIPE, STDOUT import paho.mqtt.client as mqtt import shlex -import os import random from uuid import getnode as get_mac @@ -39,7 +34,7 @@ def getAvailablePort(host, ports): def exec_ssh(port): if port == None: raise Exception('Port not avaliable') - command = 'sshpass -p' + PASSWORD + ' ssh -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -fCR ' + str(port) +':localhost:22 ' + USER + '@' + SSH_SERVER + ' sleep ' + str(ALIVE_TIME) + command = 'sshpass -p' + PASSWORD + ' ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile /dev/null" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -fCR ' + str(port) +':localhost:22 ' + USER + '@' + SSH_SERVER + ' sleep ' + str(ALIVE_TIME) print command return call(shlex.split(command), shell=False) @@ -67,7 +62,7 @@ class MyClient(mqtt.Client): if __name__ == '__main__': mac = hex(get_mac()) - id = os.getenv('USER') + '-' + '{:0>12}'.format(mac[2:13]) + id = '{:0>12}'.format(mac[2:-1]) print 'id is: ' , id client = MyClient(id) client.connect(MQTT_SERVER, MQTT_PORT, 60)