This question may be silly, but I hate when a programming language does it on me ... so I have the following function:
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 is loaded when the function is loaded ... the values are assigned to a mode.config file, which parses nicely into config (I did test it )
if __name__ == '__main__':
config = {}
execfile('C:\performance\mode.config', config)
main()
When I hardcoded the values into client.connect() it worked nicely, however, when I try to make it in the correct way (using a config file, instead of hardcoding), I get the following error:
Starting the client remotely on 123.456.795
getaddrinfo() argument 1 must be string or None
Of course client is a String: client = config['client']. Could someone please help me? The Python versions is 2.7.5.
client.connect(str(client), ...)looks rather suspicious. How could thestrof aSSHClientinstance be useful?'C:\performance\new.config'…123.456.795is not a valid IP address, double check your config! Python is not "playing a trick" on you... It's pretty much the contrary.str()is not the issue, the issue is thatclientis not the string you loaded withclient = config['client'], but theSSHClientinstance you assigned in the code posted above. Rename one of the two.