Я использую библиотеку Python Flask и пытаюсь подключиться к хосту. Проблема заключается в том, что если я сохраню имя хоста в переменной и передам в качестве аргумента, произойдет сбой с ошибкой.
Как передать переменную?
uname = request.args.get('username')
pwd = request.args.get('password')
client = request.args.get('client')
print("username entered = ", uname)
print("password entered = ", pwd)
print("FAT client = ", client)
print("Initiating connection to ", client, " and triggering SPU")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(client, username=uname, password=pwd, timeout=900) # This errors as client is a variable. If i hardcode client to a real hostname it works
paramiko.util.log_to_file("filename.log")
Кратко ошибка:
TypeError: getaddrinfo() argument 1 must be string or None
Ошибка трассировки стека:
Traceback (most recent call last):
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "D:\dev\HelloWorld\Flask_POST_PUT_test.py", line 24, in login_page
client.connect(client, username=uname, password=pwd, timeout=900)
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\paramiko\client.py", line 340, in connect
to_try = list(self._families_and_addresses(hostname, port))
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\site-packages\paramiko\client.py", line 203, in _families_and_addresses
addrinfos = socket.getaddrinfo(
File "C:\Users\rsanpui.ORADEV\AppData\Local\Programs\Python\Python38\Lib\socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
TypeError: getaddrinfo() argument 1 must be string or None