Questions tagged [ftplib]

ftplib — FTP protocol client under Python programming language

ftplib is a python module which defines the class FTP and a few related items.

The FTP class implements the client side of the FTP protocol. You can use this to write Python programs that perform a variety of automated FTP jobs, such as mirroring other ftp servers. It is also used by the module urllib.request to handle URLs that use FTP. For more information on FTP (File Transfer Protocol), see Internet RFC 959.

Read more about ftplib at python docs..

681 questions
15
votes
8 answers

Create missing directories in ftplib storbinary

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…
AliBZ
  • 4,039
  • 12
  • 45
  • 67
14
votes
3 answers

Read a file in buffer from FTP python

I am trying to read a file from an FTP server. The file is a .gz file. I would like to know if I can perform actions on this file while the socket is open. I tried to follow what was mentioned in two StackOverflow questions on reading files without…
smandape
  • 1,033
  • 2
  • 14
  • 31
13
votes
1 answer

Checking a Python FTP connection

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 =…
Leo Mizuhara
  • 365
  • 2
  • 3
  • 15
12
votes
2 answers

Python ftplib timing out

I'm trying to use ftplib to get a file listing and download any new files since my last check. The code I'm trying to run so far is: #!/usr/bin/env python from ftplib import FTP import sys host = 'ftp.***.com' user = '***' passwd = '***' try: …
Ian Burris
  • 6,325
  • 21
  • 59
  • 80
12
votes
1 answer

EOF occurred in violation of protocol with Python ftplib

I'm working on an implicit TLS connection program with Python ftplib. I tried the solution provided in question python-ftp-implicit-tls-connection-issue(including Rg Glpj's and Juan Moreno's answers) to make the connection. But when I call retrline…
Yohn
  • 580
  • 5
  • 19
12
votes
2 answers

Python ftplib: How to store results of `FTP.retrlines` in a list?

I'd like to retrieve files' name of a directory and I use the method ftplib.retrlines('NLST' + path). It prints all files' names in the directory path. But I want to store those files' names in a container, e.g., a list, instead of printing them in…
Tao Xiao
  • 259
  • 1
  • 4
  • 10
12
votes
3 answers

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

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…
jason
  • 121
  • 1
  • 1
  • 3
12
votes
2 answers

How to upload binary file with ftplib in Python?

My python2 script uploads files nicely using this method but python3 is presenting problems and I'm stuck as to where to go next (googling hasn't helped). from ftplib import FTP ftp = FTP(ftp_host, ftp_user, ftp_pass) ftp.storbinary('STOR…
Teifion
  • 108,121
  • 75
  • 161
  • 195
12
votes
1 answer

Python converting datetime to be used in os.utime

I cannot set ctime/mtime on my file within Python. First I get the original timestamp of the file through FTP. The only thing I want is to keep the original timestamps on my downloaded files using the ftplib. def getFileTime(ftp,name): try : …
havmaage
  • 143
  • 2
  • 8
12
votes
1 answer

ftp sending python bytesio stream

I want to send a file with python ftplib, from one ftp site to another, so to avoid file read/write processees. I create a BytesIO stream: myfile=BytesIO() And i succesfully retrieve a image file from ftp site one with…
jose
  • 399
  • 2
  • 14
11
votes
4 answers

Python: Reading Ftp file list with UTF-8?

Hi I am using module ftplib. And list my files with this code: files=[] files = ftp.nlst() And write them to text file with this code: for item in files: filenames.write(item +'\n') But there is an encoding problem that if my file name has…
Busra Koken
  • 273
  • 2
  • 10
10
votes
3 answers

Python: ftplib hangs at end of transfer

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…
hammus
  • 2,602
  • 2
  • 19
  • 37
9
votes
6 answers

Proxies in Python FTP application

I'm developing an FTP client in Python ftplib. How do I add proxies support to it (most FTP apps I have seen seem to have it)? I'm especially thinking about SOCKS proxies, but also other types... FTP, HTTP (is it even possible to use HTTP proxies…
Eli
8
votes
3 answers

Resume FTP download after timeout

I'm downloading files from a flaky FTP server that often times out during file transfer and I was wondering if there was a way to reconnect and resume the download. I'm using Python's ftplib. Here is the code that I am using: #!…
user8675309
  • 181
  • 2
  • 10
8
votes
1 answer

Cannot list FTP directory using ftplib – but FTP client works

I'm trying to connect to an FTP but I am unable to run any commands. ftp_server = ip ftp_username = username ftp_password = password ftp = ftplib.FTP(ftp_server) ftp.login(ftp_username, ftp_password) '230 Logged on' ftp.nlst() The ftp.nlst…
Henry Dang
  • 179
  • 3
  • 8
1
2
3
45 46