ftplib

Using ftplib for multithread uploads

那年仲夏 提交于 2019-12-07 20:11:21
问题 I'm trying to do multithread uploads, but get errors. I guessed that maybe it's impossible to use multithreads with ftplib? Here comes my code: class myThread (threading.Thread): def __init__(self, threadID, src, counter, image_name): self.threadID = threadID self.src = src self.counter = counter self.image_name = image_name threading.Thread.__init__(self) def run(self): uploadFile(self.src, self.image_name) def uploadFile(src, image_name): f = open(src, "rb") ftp.storbinary('STOR ' + image

FTP downloading freezes the whole application

╄→尐↘猪︶ㄣ 提交于 2019-12-07 19:01:23
问题 I'm trying to download a file from FTP server which is about 100 MB. It's a test .bin file because I'm testing the app and I guess the files I will want to download in the future will weight even more. When I want to download the file the whole application just freezes and then after a few seconds it downloads the file. The file is complete and it downloads it successfully without any errors or something like that. The only problem is the freeze. My code: ftp = FTP('exampledomain.com') ftp

ftps.storlines socket.timeout despite file upload completing

旧城冷巷雨未停 提交于 2019-12-06 12:54:14
问题 I'm trying to upload a CSV file using ftplib.FTP_TLS, however regardless of the timeout duration I set (5,10,60 seconds), the code always times out with the error: File "/usr/lib/python3.4/ftplib.py", line 544, in storlines conn.unwrap() File "/usr/lib/python3.4/ssl.py", line 788, in unwrap s = self._sslobj.shutdown() socket.timeout: The read operation timed out However after the timeout, I check the directory through Cyberduck, and the CSV file is there, complete. Here is my upload code: def

ftplib: socket.error during/after LIST // ssl._sslobj.shutdown() / connection timed out

时光毁灭记忆、已成空白 提交于 2019-12-06 10:44:30
问题 I try to connect to a FTPS server using a client certificate. I tried on 2 different servers (over which I've no control but that should be quite similar). The connection is established and the PWD command succeeds. On one server the LIST command succeed but on the second one, it produces the right result (the list of files) but generates an error after (apparently during the SSL shutdown). On the server side, they told me: "Your LIST command is passing correctly but afterward you loose the

Using ftplib for multithread uploads

我是研究僧i 提交于 2019-12-06 06:45:21
I'm trying to do multithread uploads, but get errors. I guessed that maybe it's impossible to use multithreads with ftplib? Here comes my code: class myThread (threading.Thread): def __init__(self, threadID, src, counter, image_name): self.threadID = threadID self.src = src self.counter = counter self.image_name = image_name threading.Thread.__init__(self) def run(self): uploadFile(self.src, self.image_name) def uploadFile(src, image_name): f = open(src, "rb") ftp.storbinary('STOR ' + image_name, f) f.close() ftp = FTP('host') # connect to host, default port ftp.login() # user anonymous,

ftplib: socket.error during/after LIST // ssl._sslobj.shutdown() / connection timed out

眉间皱痕 提交于 2019-12-04 15:47:31
I try to connect to a FTPS server using a client certificate. I tried on 2 different servers (over which I've no control but that should be quite similar). The connection is established and the PWD command succeeds. On one server the LIST command succeed but on the second one, it produces the right result (the list of files) but generates an error after (apparently during the SSL shutdown). On the server side, they told me: "Your LIST command is passing correctly but afterward you loose the connection during a new SSL re-negociation." Any idea why? Thanks in advance. . The common commands to

Connect to FTP server through http proxy

爱⌒轻易说出口 提交于 2019-12-04 15:03:52
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.ProxyHandler({'http': proxy_url}) opener = urllib.request.build_opener(proxy_support) urllib.request

Checking a Python FTP connection

人盡茶涼 提交于 2019-12-04 12:14:25
问题 I have a FTP connection from which I am downloading many files and processing them in between. I'd like to be able to check that my FTP connection hasn't timed out in between. So the code looks something like: conn = FTP(host='blah') conn.connect() for item in list_of_items: myfile = open('filename', 'w') conn.retrbinary('stuff", myfile) ### do some parsing ### How can I check my FTP connection in case it timed out during the ### do some parsing ### line? 回答1: Send a NOOP command. This does

Create missing directories in ftplib storbinary

北战南征 提交于 2019-12-04 01:50:42
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? FTP_CREATE_MISSING_DIRS is a curl operation ( added here ). I'd hazard a guess that you have to do it manually with ftplib, but I'd love to be proven wrong, anyone? I'd do something like the following: (untested, and need

Change directory on server before uploading files with ftplib in Python

孤街醉人 提交于 2019-12-03 22:49:54
问题 This question was migrated from Super User because it can be answered on Stack Overflow. Migrated 2 years ago . I have this code, but I can't figure out how to change directory on the server before uploading files. Can anyone help me out? import ftplib import os server = 'enter your servername here' username = 'root' password = 'passowrd' myFTP = ftplib.FTP(server, username, password) myPath = r'C:\path_of_the_folder_goes_here' def uploadThis(path): files = os.listdir(path) os.chdir(path) for