I am using your ftputil within a python script

1k Views Asked by At

I am using your ftputil within a python script to get last modification/creation date of files in directory and I am having few problems and wondered if you could help.

      host.stat_cache.resize(200000)
 recursive = host.walk(directory, topdown=True, onerror=None)
  for root,dirs,files in recursive:
       for name in files:
            #mctime = host.stat(name).mtime
            print name

The above outputs a listing of all files in the directory

      host.stat_cache.resize(200000)
 recursive = host.walk(directory, topdown=True, onerror=None)
 for root,dirs,files in recursive:
       for name in files:
          if host.path.isfile("name"):
             mtime1 = host.stat("name")
             mtime2 = host.stat("name").mtime
             #if crtime < now -30 * 86400:
             #print name + " Was Created " + " " + crtime + " " + mtime
             print name + " Was Created " + " " + " " + mtime1 + " " + mtime2

Above produces no output

1

There are 1 best solutions below

0
Daniel Roseman On

You've put name in quotes. So Python will always be checking for the literal filename "name", which presumably doesn't exist. You mean:

      if host.path.isfile(name):
         mtime1 = host.stat(name)
         mtime2 = host.stat(name).mtime