ftplib

Connect to FTP server through http proxy

故事扮演 提交于 2019-12-21 22:09:12
问题 My code belove gives me the error: socket.gaierror: [Errno 11001] getaddrinfo failed when calling the method ftp.connect(). My question is: why can I connect to google.com but when connecting to an ftp server it gives me error? And how I can connect to the ftp server from behind http proxy? import ftplib import urllib.request # ftp settings ftpusername = 'abc' ftppassword = 'xyz' ftp_host = 'host' ftp_port = 1234 proxy_url = 'http://username:password@host:port' proxy_support = urllib.request

Retrieve data from gz file on FTP server without writing it locally

别来无恙 提交于 2019-12-21 06:30:20
问题 I would like to retrieve the data inside a compressed gz file stored on an FTP server, without writing the file to the local archive. At the moment I have done from ftplib import FTP import gzip ftp = FTP('ftp.server.com') ftp.login() ftp.cwd('/a/folder/') fileName = 'aFile.gz' localfile = open(fileName,'wb') ftp.retrbinary('RETR '+fileName, localfile.write, 1024) f = gzip.open(localfile,'rb') data = f.read() This, however, writes the file "localfile" on the current storage. I tried to change

Create missing directories in ftplib storbinary

孤街醉人 提交于 2019-12-21 03:43:43
问题 I was using pycurl to transfer files over ftp in python. I could create the missing directories automatically on my remote server using: c.setopt(pycurl.FTP_CREATE_MISSING_DIRS, 1) for some reasons, I have to switch to ftplib. But I don't know how to to the same here. Is there any option to add to storbinary function to do that? or I have to create the directories manually? 回答1: FTP_CREATE_MISSING_DIRS is a curl operation (added here). I'd hazard a guess that you have to do it manually with

Python: ftplib hangs at end of transfer

怎甘沉沦 提交于 2019-12-21 02:38:42
问题 I been searching on this for a couple of days and havent found an answer yet. I have trying to download video files from an FTP, my script checks the server, compares the nlist() to a list of already downloaded files parsed from a text file and then creates a new list of files to get and iterates over it downloading each file, disconnecting from the server and reconnecting for the next file (I thought server timeout might be an issue so I quit() the connection after each file download). This

ftplib.FTP timeout has inconsistent behaviour

安稳与你 提交于 2019-12-20 02:15:59
问题 I am trying to use ftplib.FTP() with timeout option as some timeout value for a particular hostname. But i am experiencing weird behaviour. To test it i have written a very simple piece of code. import ftplib from ftplib import FTP ftp = ftplib.FTP("google.com",timeout=2) The API document says to enter timeout value in seconds, but it seems that it takes longer than that, for me it almost takes more than 8 secs. Can anybody please explain the behaviour.I am using python2.7 回答1: ftplib.FTP

Python ftplib can't get size of file before download?

杀马特。学长 韩版系。学妹 提交于 2019-12-19 05:44:55
问题 I'm using ftplib to transfer files. Everything is working great. Now I'm trying to get the size of the target file before downloading. First, I tried just getting size with ftp.size(filename). Server complained that I can't do that in ascii mode. Then I tried setting binary mode using ftp.sendcmd("binary") and ftp.sendcmd("bin"). In both cases the server complained "500 binary Not understood" Can ftplib get size of a file before downloading in this instance? I don't control the FTP server and

Python ftplib can't get size of file before download?

江枫思渺然 提交于 2019-12-19 05:44:11
问题 I'm using ftplib to transfer files. Everything is working great. Now I'm trying to get the size of the target file before downloading. First, I tried just getting size with ftp.size(filename). Server complained that I can't do that in ascii mode. Then I tried setting binary mode using ftp.sendcmd("binary") and ftp.sendcmd("bin"). In both cases the server complained "500 binary Not understood" Can ftplib get size of a file before downloading in this instance? I don't control the FTP server and

FTP download with text label showing the current status of the download

孤街浪徒 提交于 2019-12-19 04:16:05
问题 I made a GUI in which after I click "Download" button the program will download files from FTP server. When doing that I want the label to update e.g: "Connecting..." -> "Downloading..." -> "Downloaded!" I tried doing it with threading module but it seems to not work: def updater(self): self.updateStatusText.setText("Status: Connecting...") thread = threading.Thread(target=self.download) thread.start() while thread.isAlive(): self.updateStatusText.setText("Status: Still Downloading...") def

FTP download with text label showing the current status of the download

落花浮王杯 提交于 2019-12-19 04:16:00
问题 I made a GUI in which after I click "Download" button the program will download files from FTP server. When doing that I want the label to update e.g: "Connecting..." -> "Downloading..." -> "Downloaded!" I tried doing it with threading module but it seems to not work: def updater(self): self.updateStatusText.setText("Status: Connecting...") thread = threading.Thread(target=self.download) thread.start() while thread.isAlive(): self.updateStatusText.setText("Status: Still Downloading...") def

Python - Upload a in-memory file (generated by API calls) in FTP by chunks

╄→尐↘猪︶ㄣ 提交于 2019-12-18 07:19:58
问题 I need to be able to upload a file through FTP and SFTP in Python but with some not so usual constraints. File MUST NOT be written in disk. The file how it is generated is by calling an API and writing the response which is in JSON to the file. There are multiple calls to the API. It is not possible to retrieve the whole result in one single call of the API. I can not store in a string variable the full result by doing the multiple calls needed and appending in each call until I have the