359 # Try to retrieve as a file |
359 # Try to retrieve as a file |
360 try: |
360 try: |
361 cmd = 'RETR ' + file |
361 cmd = 'RETR ' + file |
362 conn = self.ftp.ntransfercmd(cmd, rest) |
362 conn = self.ftp.ntransfercmd(cmd, rest) |
363 except ftplib.error_perm, reason: |
363 except ftplib.error_perm, reason: |
364 if str(reason)[:3] == '501': |
364 if str(reason).startswith('501'): |
365 # workaround for REST not supported error |
365 # workaround for REST not supported error |
366 fp, retrlen = self.retrfile(file, type) |
366 fp, retrlen = self.retrfile(file, type) |
367 fp = RangeableFileObject(fp, (rest,'')) |
367 fp = RangeableFileObject(fp, (rest,'')) |
368 return (fp, retrlen) |
368 return (fp, retrlen) |
369 elif str(reason)[:3] != '550': |
369 elif not str(reason).startswith('550'): |
370 raise IOError, ('ftp error', reason), sys.exc_info()[2] |
370 raise IOError, ('ftp error', reason), sys.exc_info()[2] |
371 if not conn: |
371 if not conn: |
372 # Set transfer mode to ASCII! |
372 # Set transfer mode to ASCII! |
373 self.ftp.voidcmd('TYPE A') |
373 self.ftp.voidcmd('TYPE A') |
374 # Try a directory listing |
374 # Try a directory listing |