I'm fetching a list with all files/folders on a ftp-server,
I want to put a [F] before a folder, and leave files like they are,
but I can't find a way to check if it's a file or a dir...
I already tried:
from ftplib import FTP
import os
ftp = FTP(self.host)
listdir = self.ftp.nlst()
for i in listdir:
if(self.ftp.sendcmd(os.path.isdir(bool(self.ftpdir + "/" + i)))):
self.list_box_2.Append("[F] " + i)
But this ends in an error:
Traceback (most recent call last):
File "./DCM/dcm", line 714, in ftp_start
self.start_ftp()
File "./DCM/dcm", line 671, in start_ftp
self.ftp_show_dir()
File "./DCM/dcm", line 678, in ftp_show_dir
if(self.ftp.sendcmd(os.path.isdir(str(self.ftpdir + "/" + i)))):
File "/usr/lib/python2.6/ftplib.py", line 242, in sendcmd
self.putcmd(cmd)
File "/usr/lib/python2.6/ftplib.py", line 177, in putcmd
self.putline(line)
File "/usr/lib/python2.6/ftplib.py", line 170, in putline
line = line + CRLF
TypeError: unsupported operand type(s) for +: 'bool' and 'str'