473,842 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(se lf, file, filename):
'''A method to upload a file via ftp'''
ftpserverloc = self.getItunesU ftpServer()
ftpserveruserna me = self.getItunesU ftpUser()
ftpserverpasswo rd = self.getItunesU ftpPsswd()
ftp = ftplib.FTP(ftps erverloc)
ftp.login(ftpse rverusername, ftpserverpasswo rd)
try:
ftp.storbinary( "STOR " + filename, file, 1024)
finally:
file.close()
ftp.quit()
And here's the traceback:
Traceback (innermost last):
Module ZPublisher.Publ ish, line 114, in publish
Module ZPublisher.mapp ly, line 88, in mapply
Module ZPublisher.Publ ish, line 40, in call_object
Module Products.FileSy stemSite.FSPyth onScript, line 108, in __call__
Module Shared.DC.Scrip ts.Bindings, line 311, in __call__
Module Shared.DC.Scrip ts.Bindings, line 348, in _bindAndExec
Module Products.FileSy stemSite.FSPyth onScript, line 164, in _exec
Module None, line 28, in upload_submit
- <FSPythonScri pt at
/silva/service_views/UCLItunesUPodca st/edit/Asset/UCLItunesUTrack/upload_sub
mit>
- Line 28
Module Products.UCLItu nesUPodcast.UCL ItunesUService, 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 6626
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(se lf, file, filename):
'''A method to upload a file via ftp'''
ftpserverloc = self.getItunesU ftpServer()
ftpserveruserna me = self.getItunesU ftpUser()
ftpserverpasswo rd = self.getItunesU ftpPsswd()
ftp = ftplib.FTP(ftps erverloc)
ftp.login(ftpse rverusername, ftpserverpasswo rd)
try:
ftp.storbinary( "STOR " + filename, file, 1024)
finally:
file.close()
ftp.quit()
And here's the traceback:
Traceback (innermost last):
Module ZPublisher.Publ ish, line 114, in publish
Module ZPublisher.mapp ly, line 88, in mapply
Module ZPublisher.Publ ish, line 40, in call_object
Module Products.FileSy stemSite.FSPyth onScript, line 108, in __call__
Module Shared.DC.Scrip ts.Bindings, line 311, in __call__
Module Shared.DC.Scrip ts.Bindings, line 348, in _bindAndExec
Module Products.FileSy stemSite.FSPyth onScript, line 164, in _exec
Module None, line 28, in upload_submit
- <FSPythonScri pt at
/silva/service_views/UCLItunesUPodca st/edit/Asset/UCLItunesUTrack/upload_sub
mit>
- Line 28
Module Products.UCLItu nesUPodcast.UCL ItunesUService, 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
2276
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 minutes from 15 to 130) downloading a 150 MB BINARY file (a big gzipped ascii file) with the traceback reported below. IMVHO this is not a timeout error because my script import
0
3014
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 ftp.nlst() returns an empty list which seems somehow strange to me. Here is, what I did: >>> from ftplib import FTP >>> HOST = 'my.server' >>> USER = 'myuser'
2
9594
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 *' with no success. I am using the following: srcFtp = FTP(srcHost) srcFtp.login(srcUser, srcPass) srcDir = srcFtp.nlst('.')
1
1809
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
10945
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10314
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7858
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7038
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5696
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4499
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4089
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.