Bugs item #1168983, was opened at 2005-03-23 10:05 Message generated for change (Comment added) made by vmlinuxz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1168983&group_id=5470
Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: David Carroll (vmlinuxz) Assigned to: Nobody/Anonymous (nobody) Summary: ftplib.py string index out of range Initial Comment: The following code works great on all of the 2.3.x releases I have used. def ftpFetch(localPath,remoteFileDate,ftpSite,ftpPass,ftpDir,ftpUser): print "Fetching split_mgr report" fileList=[] processList=[] ftp = FTP(ftpSite) ftp.login(ftpUser,ftpPass) ftp.dir('LIST '+ftpDir,fileList.append) for x in range(len(fileList)): if (string.find(fileList[x],remoteFileDate) != -1): print fileList[x] TMP=fileList[x] output=localPath+str(TMP[45:]) print output processList.append(output) print processList outfile = open(output,'w') ftp.retrbinary('RETR '+ftpDir+TMP[45:], open(output, 'wb').write) ftp.quit() print processList return processList However I get the following error under 2.4 Traceback (most recent call last): File "C:\Python24\lib\site-packages\PythonCard\widget.py", line 417, in _dispatch handler(background, aWxEvent) File "C:\Documents and Settings\PROTECTED\Desktop\ReadWaitReport\ReadWaitReport\readwaitreport.py", line 61, in on_btnRun_command mainRwclassLoop(self, mm+dd+yy, yesterday) File "C:\Documents and Settings\PROTECTED\Desktop\ReadWaitReport\ReadWaitReport\rwclass.py", line 39, in mainRwclassLoop processList = ftpFetch(localPath,"split_mgr."+date[0:4],ftpSite,ftpPass,ftpDir,ftpUser) File "C:\Documents and Settings\PROTECTED\Desktop\ReadWaitReport\ReadWaitReport\rwclass.py", line 173, in ftpFetch ftp.dir('LIST '+ftpDir,fileList.append) File "C:\Python24\lib\ftplib.py", line 464, in dir self.retrlines(cmd, func) File "C:\Python24\lib\ftplib.py", line 396, in retrlines conn = self.transfercmd(cmd) File "C:\Python24\lib\ftplib.py", line 345, in transfercmd return self.ntransfercmd(cmd, rest)[0] File "C:\Python24\lib\ftplib.py", line 328, in ntransfercmd if resp[0] != '1': IndexError: string index out of range https://lists.dulug.duke.edu/pipermail/yum/2004-August/005067.html discusses a similar problem under Linux in the YUM script, I have reproduced this error under 2000, and XP. I'm a fairly new programmer, and thus very new to python so I hope this is enough information. I will try and keep track of this and help out with more information in any capacity I can. Thank you for all your hard work and dedication. David Carroll ---------------------------------------------------------------------- >Comment By: David Carroll (vmlinuxz) Date: 2005-04-08 10:13 Message: Logged In: YES user_id=684143 I achieve the same results with the following code. ftp = FTP('ftp.cdrom.com') ftp.login('anonymous', 'anonymous@') ftp.retrlines('LIST') This code works just fine with your patched ftplib.py, or the old ftplib.py against all public internet ftp servers I have tried it on. It works on the server at work only sporadically,, and raising the protocol exception the rest of the time. I'm inclined to think that there may be a problem with the protocol implementation on the server side. The server software version is wu-2.6.2(1), and the only oddity I see with it is a pretty sizeable delay before giving the login. Up to 10 seconds. I'd love to get a pointer of where to take this debugging process next. Perhaps I need to use a sniffer on the connection or something. I would love to see what ftplib.py is getting back that is breaking it. ---------------------------------------------------------------------- Comment By: David Carroll (vmlinuxz) Date: 2005-04-07 09:51 Message: Logged In: YES user_id=684143 Thank you for leaving this open. I will try and get your example today. I'm too uneducated to realize what I'm doing wrong, so maybe you can use my ignorance for the common good =). ---------------------------------------------------------------------- Comment By: Raymond Hettinger (rhettinger) Date: 2005-04-05 04:31 Message: Logged In: YES user_id=80475 I fixed the IndexError. It should have been a protocol error. See Lib/ftplib.py 1.74. Leaving the bug open so the OP can make a more detailed post so we can see what the root issue is about. ---------------------------------------------------------------------- Comment By: Ilya Sandler (isandler) Date: 2005-04-05 03:37 Message: Logged In: YES user_id=971153 It turns out that the code in plain text bug report is more or less readable, so I can see what you were trying to do... Seems like you are doing ftp.dir("LIST "+ftpDir) But ftplib docs: http://www.python.org/doc/current/lib/ftp-objects.html say that you need to specify the directory ftp.dir(ftpDir) so it seems that you are using ftp.dir() incorrectly.... But, even then IndexError seems like a wrong kind of exception for this kind of error... So, I guess, my original request for a working code snippet which would allow to reproduce the bug still stands.. ---------------------------------------------------------------------- Comment By: Ilya Sandler (isandler) Date: 2005-04-05 02:12 Message: Logged In: YES user_id=971153 Could you submit a minimalistic piece of code which illustrates the problem? As well as any input data which are required to reproduce it? (SourceForge garbled your original example) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1168983&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com