Jan-21-2019, 06:00 PM
Hi, I use paramiko on python 3.7.1 for simple file manipulation between a Raspberry pi with SSH.
the connection work, I can open my file and I have no problem with read and write. The only one problem is 'get'
the connection work, I can open my file and I have no problem with read and write. The only one problem is 'get'
import paramiko import os from paramiko import sftp_handle fortyone=41 localFile="C:\data\data.txt" localpath="C:\data\data.txt" remotepath="/home/pi/SiteCyberdependance/data/data.txt" file="/home/pi/Sitecyberdependance/data/data.txt" line=0 read = paramiko.SFTPFile.read get = paramiko.SFTPClient.get put = paramiko.SFTPClient.put remove = paramiko.SFTPClient.remove host = "41.41.41.41" port = 22 transport = paramiko.Transport((host, port)) password = "414141" username = "pi" transport.connect(username = username, password = password) sftp = paramiko.SFTPClient.from_transport(transport) sftp.open("/home/pi/Sitecyberdependance/data/data.txt",mode='r+w', bufsize=-1) self="/home/pi/Sitecyberdependance/data/data.txt" #I dosen't think is the corect way I need to use 'self' rigth?# # this is the line the error occur# get(self, remotepath, localpath, callback=None) while fortyone==41: with open("C:\data\data.txt", "r") as search: for line in search: line = line.rstrip('\n') line+1 lines = open("C:\data\data.txt").read().splitlines() lines[1] = line open("C:\data\data.txt",'w').write('\n'.join(lines)) remove(self, "/home/pi/Sitecyberdependance/data/data.txt") put(localpath, remotepath, callback=None, confirm=True) remove(self, "C:\data\data.txt")and the error
Error:Traceback (most recent call last):
File "C:\pythonprogram\sshtest.py", line 29, in <module>
get(self, remotepath, localpath, callback=None)
File "C:\python\lib\site-packages\paramiko\sftp_client.py", line 802, in get
size = self.getfo(remotepath, fl, callback)
AttributeError: 'str' object has no attribute 'getfo'
this is it. if you can explain me brifly what 'self' do, what I need to change for resolve this problem, how I can improve my program and any mistake I have do.