[ftputil] Ftputil seems really slow to distinguish file and folders

MailingList SVR lists at svrinformatica.it
Wed Apr 29 22:46:56 CEST 2009


Hi Stefan,

I need to distinguish beetween file and folder, I'm using host.path.isdir and host.path.isfile but these seems really slow.

Here is an example code:

host=ftputil.FTPHost('ftp.nluug.nl','anonymous','pippo at pippo.com')

folder='/vol/1/centoslinux/5.3/os/SRPMS/'

lista=host.listdir(folder)

# host.listdir is fast, good!

for l in lista:
        print folder+l
        print datetime.datetime.now()
       #host.path.isdir and isfile are slow :-(
        if host.path.isdir(folder+l):
                print 'dir:'
                print datetime.datetime.now()
        if host.path.isfile(folder+l):
                print 'file:'


and this is the output:

/vol/1/centoslinux/5.3/os/SRPMS/Cluster_Administration-5.2-1.el5.centos.src.rpm
2009-04-29 22:39:53.646165                                                     
file:                                                                          
2009-04-29 22:39:54.917435                                                     
/vol/1/centoslinux/5.3/os/SRPMS/Deployment_Guide-5.2-11.el5.centos.src.rpm     
2009-04-29 22:39:54.917775
file:
2009-04-29 22:39:56.248630
/vol/1/centoslinux/5.3/os/SRPMS/ElectricFence-2.2.2-20.2.2.src.rpm
2009-04-29 22:39:56.249002
file:
2009-04-29 22:39:57.563621
/vol/1/centoslinux/5.3/os/SRPMS/GConf2-2.14.0-9.el5.src.rpm
2009-04-29 22:39:57.563988
file:
2009-04-29 22:39:58.832466
/vol/1/centoslinux/5.3/os/SRPMS/Global_File_System-5.2-1.el5.centos.src.rpm
2009-04-29 22:39:58.832842
file:
2009-04-29 22:40:00.104433
/vol/1/centoslinux/5.3/os/SRPMS/ImageMagick-6.2.8.0-4.el5_1.1.src.rpm
2009-04-29 22:40:00.104776

as you can see this method is really slow. I think I'm missing something ... distinguish files and folders is the main function of every ftp frontend, can you point me towards the right approach?

thanks
Nicola


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/ftputil/attachments/20090429/ebd3c829/attachment-0001.htm 


More information about the ftputil mailing list