'str' object has no attribute 'getfo' (Paramiko) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: 'str' object has no attribute 'getfo' (Paramiko) (/thread-15551.html) |
'str' object has no attribute 'getfo' (Paramiko) - lateublegende - Jan-21-2019 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' 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 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.
RE: 'str' object has no attribute 'getfo' (Paramiko) - ichabod801 - Jan-21-2019 'self' is for classes. It is automatically given as a parameter when an instance method is called. I am not familiar with Paramiko, but it looks like get is a method of the SFTPClient class, which sftp is an instance of in your code. If so, this should work: sftp.get(remotepath, localpath, callback = None) RE: 'str' object has no attribute 'getfo' (Paramiko) - lateublegende - Jan-23-2019 that work. thank for you reply! |