AttributeError:'NoneType'对象没有属性'time'paramiko [英] AttributeError: 'NoneType' object has no attribute 'time' paramiko
本文介绍了AttributeError:'NoneType'对象没有属性'time'paramiko的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import paramiko
key = paramiko.RSAKey.from_private_key_file("abc.pem")
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("connecting")
ssh.connect(hostname="1.1.1.1", username="abc", pkey=key)
print("connected")
commands = "ip a"
stdin, stdout, stderr = ssh.exec_command(commands)
print(stdout.read())
print(stderr.read())
print(stdin.read())
ssh.close()
为什么有时会出现 AttributeError:'NoneType'对象在Python3.8中没有属性'time'
,有时需要等待很长时间才能显示为结果(或者我怎么看待进程)
Why have sometime will AttributeError: 'NoneType' object has no attribute 'time'
in Python3.8 and sometime need wait long time show as result(or how can i see process)
错误代码:
Exception ignored in: <function BufferedFile.__del__ at 0x108271ee0>
Traceback (most recent call last):
File "/venv/lib/python3.8/site-packages/paramiko/file.py", line 66, in __del__
File "/venv/lib/python3.8/site-packages/paramiko/channel.py", line 1392, in close
File "/venv/lib/python3.8/site-packages/paramiko/channel.py", line 991, in shutdown_write
File "/venv/lib/python3.8/site-packages/paramiko/channel.py", line 967, in shutdown
File "/venv/lib/python3.8/site-packages/paramiko/transport.py", line 1846, in _send_user_message
AttributeError: 'NoneType' object has no attribute 'time'
高级
我该如何使用paramiko double ssh
how can i use paramiko double ssh
本地主机>> a(服务器)ssh >> b
localhost >> a(server) ssh >> b
推荐答案
也许您可以尝试以下方法:
Maybe you can try something like this:
stdin, stdout, stderr = ssh.exec_command(commands)
time.sleep(5)
(不要忘记导入时间)
这似乎增加了更多时间来处理命令
This seems to add more time to process the command
这篇关于AttributeError:'NoneType'对象没有属性'time'paramiko的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文