この質問はばかげているかもしれませんが、プログラミング言語が私にそれを行うのは嫌いです...だから私は次の機能を持っています:
def udp_server(client=""):
mutex.acquire()
try:
print "Starting server ... "
server_process = subprocess.Popen("iperf.exe -s -u -i 1 -l 872",
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
print "Server started at ", server_process.pid
print "Starting the client remotely on %s" % client
cmd = "cd C:/performance/Iperf && python iperf_udp_client.py -c %s" % client
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
client.connect(str(client), username=str(config['ssh_user']),
password=str(config['ssh_pwd']))
stdin, stdout, stderr = client.exec_command(cmd)
print stdout.readlines()
server_process.kill()
except Exception, e:
print e
finally:
mutex.release()
config
関数が読み込まれるときに読み込まれます...値はmode.config
ファイルに割り当てられ、うまく解析されますconfig
(私はそれをテストしました)
if __name__ == '__main__':
config = {}
execfile('C:\performance\mode.config', config)
main()
値をハードコーディングするclient.connect()
とうまくいきましたが、正しい方法で (ハードコーディングではなく構成ファイルを使用して) 作成しようとすると、次のエラーが発生します。
Starting the client remotely on 123.456.795
getaddrinfo() argument 1 must be string or None
もちろんclient
String:client = config['client']
です。誰か助けてくれませんか?Python のバージョンは2.7.5
.