<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:10pt; font-weight:400; font-style:normal;">Hi Stefan,<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>I need to distinguish beetween file and folder, I'm using host.path.isdir and host.path.isfile but these seems really slow.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Here is an example code:<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>host=ftputil.FTPHost('ftp.nluug.nl','anonymous','pippo@pippo.com')<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>folder='/vol/1/centoslinux/5.3/os/SRPMS/'<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>lista=host.listdir(folder)<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p># host.listdir is fast, good!<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>for l in lista:<br>
        print folder+l<br>
        print datetime.datetime.now()<br>
       #host.path.isdir and isfile are slow :-(<br>
        if host.path.isdir(folder+l):<br>
                print 'dir:'<br>
                print datetime.datetime.now()<br>
        if host.path.isfile(folder+l):<br>
                print 'file:'<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>and this is the output:<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>/vol/1/centoslinux/5.3/os/SRPMS/Cluster_Administration-5.2-1.el5.centos.src.rpm<br>
2009-04-29 22:39:53.646165                                                     <br>
file:                                                                          <br>
2009-04-29 22:39:54.917435                                                     <br>
/vol/1/centoslinux/5.3/os/SRPMS/Deployment_Guide-5.2-11.el5.centos.src.rpm     <br>
2009-04-29 22:39:54.917775<br>
file:<br>
2009-04-29 22:39:56.248630<br>
/vol/1/centoslinux/5.3/os/SRPMS/ElectricFence-2.2.2-20.2.2.src.rpm<br>
2009-04-29 22:39:56.249002<br>
file:<br>
2009-04-29 22:39:57.563621<br>
/vol/1/centoslinux/5.3/os/SRPMS/GConf2-2.14.0-9.el5.src.rpm<br>
2009-04-29 22:39:57.563988<br>
file:<br>
2009-04-29 22:39:58.832466<br>
/vol/1/centoslinux/5.3/os/SRPMS/Global_File_System-5.2-1.el5.centos.src.rpm<br>
2009-04-29 22:39:58.832842<br>
file:<br>
2009-04-29 22:40:00.104433<br>
/vol/1/centoslinux/5.3/os/SRPMS/ImageMagick-6.2.8.0-4.el5_1.1.src.rpm<br>
2009-04-29 22:40:00.104776<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>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?<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>thanks<br>
Nicola<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p></body></html>