I am looking to automate file retrieval from a python program that gets a file from my Raspberry Pi and returns it to my local PC. I have tried SSH, FTP & SCP but can't get any to work and run into connection problems in my Python program. Any one have a quick code snippet. below is the code I think should work but getting an error
-IDE: Pycharm
NOTE: Connected to same network, ssh, putty, cmd line SCP, remote desktop work to PI but I can't do the same by just running a python program to get a file.
Filename: testfile.jpg Pi: Directory. /home/pi/testfile.jpg
Open to any method to retrieve file as long as it can do it automagically?
Ideas?
Thank you!
Code failing with Cryptography deprecation error
Code won't make simple connection - feel its on my local pC?
from paramiko import SSHClient
from scp import SCPClient
ssh = SSHClient()
ssh.Connect(ipadd.re.ss)
CAN'T GET PAST HERE ERROR BELOW
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())
Have you heard of Paramiko? It's an SSH client for Python.
You could do something like:
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)