473,287 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

ftplib returns EOFError

Hi All,

I've written a little method to connect to an ftpserver which works well,
however when I send a file using this ftp connection oddly I _sometimes_ get
returned an EOFError from ftplib.getline even though my file is actually
transferred.

Here's my script:

def uploadViaFtp(self, file, filename):
'''A method to upload a file via ftp'''
ftpserverloc = self.getItunesUftpServer()
ftpserverusername = self.getItunesUftpUser()
ftpserverpassword = self.getItunesUftpPsswd()
ftp = ftplib.FTP(ftpserverloc)
ftp.login(ftpserverusername, ftpserverpassword)
try:
ftp.storbinary("STOR " + filename, file, 1024)
finally:
file.close()
ftp.quit()
And here's the traceback:
Traceback (innermost last):
Module ZPublisher.Publish, line 114, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 40, in call_object
Module Products.FileSystemSite.FSPythonScript, line 108, in __call__
Module Shared.DC.Scripts.Bindings, line 311, in __call__
Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
Module Products.FileSystemSite.FSPythonScript, line 164, in _exec
Module None, line 28, in upload_submit
- <FSPythonScript at
/silva/service_views/UCLItunesUPodcast/edit/Asset/UCLItunesUTrack/upload_sub
mit>
- Line 28
Module Products.UCLItunesUPodcast.UCLItunesUService, line 138, in
uploadViaFtp
Module ftplib, line 523, in quit
Module ftplib, line 246, in voidcmd
Module ftplib, line 221, in voidresp
Module ftplib, line 207, in getresp
Module ftplib, line 193, in getmultiline
Module ftplib, line 183, in getline
EOFError
Any help in catching and ignoring this error would be greatly appreciated.

Regards

Jon

Jun 27 '08 #1
1 6252
On Mon, 19 May 2008 13:27:23 +0100, Jon Bowlas wrote:
Hi All,

I've written a little method to connect to an ftpserver which works well,
however when I send a file using this ftp connection oddly I _sometimes_ get
returned an EOFError from ftplib.getline even though my file is actually
transferred.

Here's my script:

def uploadViaFtp(self, file, filename):
'''A method to upload a file via ftp'''
ftpserverloc = self.getItunesUftpServer()
ftpserverusername = self.getItunesUftpUser()
ftpserverpassword = self.getItunesUftpPsswd()
ftp = ftplib.FTP(ftpserverloc)
ftp.login(ftpserverusername, ftpserverpassword)
try:
ftp.storbinary("STOR " + filename, file, 1024)
finally:
file.close()
ftp.quit()
And here's the traceback:
Traceback (innermost last):
Module ZPublisher.Publish, line 114, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 40, in call_object
Module Products.FileSystemSite.FSPythonScript, line 108, in __call__
Module Shared.DC.Scripts.Bindings, line 311, in __call__
Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
Module Products.FileSystemSite.FSPythonScript, line 164, in _exec
Module None, line 28, in upload_submit
- <FSPythonScript at
/silva/service_views/UCLItunesUPodcast/edit/Asset/UCLItunesUTrack/upload_sub
mit>
- Line 28
Module Products.UCLItunesUPodcast.UCLItunesUService, line 138, in
uploadViaFtp
Module ftplib, line 523, in quit
Module ftplib, line 246, in voidcmd
Module ftplib, line 221, in voidresp
Module ftplib, line 207, in getresp
Module ftplib, line 193, in getmultiline
Module ftplib, line 183, in getline
EOFError
Any help in catching and ignoring this error would be greatly appreciated.

Regards

Jon
ftp.quit() attempts to send a quit command and wait for the response
before closing. Apparently, sometime the connection is already closed
(don't know why) and you get the exception.

I guess you could do something like this:

try:
ftp.quit()
except EOFError:
ftp.close()
Ciao
-----
FB
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: siggy2 | last post by:
Hi, I'm using Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 I've noticed a strange (= not deterministic) behaviour of ftplib.py: sometimes (not always) it fails (after a variable number of...
0
by: Nico Grubert | last post by:
Hi there, I am using the ftplib library to connect to a ftp server. After I got connected, I can see a list of file in the current directory using ftp.dir() or ftp.retrlines('LIST'). But using...
2
by: Harlin Seritt | last post by:
Using ftplib from Python I am trying to get all files in a particular directory using ftplib and then send those same files to another ftp server. I have tried using commands like 'get *' and 'mget...
1
by: rohan1987 | last post by:
Is there a function similar to the sizeof() function used with strings that returns the number of bits used to represent an integer?
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.