Python 从 Raspberry Pi 抓取文件的程序

Python program to grab a file off of Raspberry Pi

我正在寻找从 python 程序自动检索文件的方法,该程序从我的 Raspberry Pi 和 returns 获取文件到我的本地 PC。我尝试过 SSH、FTP 和 SCP,但无法正常工作,运行 进入我的 Python 程序中的连接问题。任何人都有一个快速的代码片段。下面是我认为应该有效但出现错误的代码

-IDE: Pycharm

注意:连接到同一个网络,ssh,putty,cmd line SCP,远程桌面工作到 PI 但我不能通过 运行ning 一个 python 程序来做同样的事情一份文件。

文件名:testfile.jpg Pi:目录。 /home/pi/testfile.jpg

只要能自动取回文件的方法都可以打开吗?

想法?

谢谢!


代码因密码弃用错误而失败

代码不会建立简单的连接 - 在我的本地 pC 上感觉它?

from paramiko import SSHClient
from scp import SCPClient

ssh = SSHClient()
ssh.Connect(ipadd.re.ss)

无法通过此处错误下方

Error: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding. m.add_string(self.Q_C.public_numbers().encode_point())

你听说过Paramiko吗?它是 Python 的 SSH 客户端。

你可以这样做:

client.connect(...)
i, o, e = client.exec_command('cat /home/pi/testfile.jpg')
with open('testfile.jpg', 'wb') as f:
    for line in o:
        # these are lines in the file.
        f.write(line)