Hi,
I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). This is what I have so far:

import shutil
import signal, os

def handler(signum, frame):
   print 'Signal handler called with signal', signum
   raise IOError, "Couldn't open device!"

signal.signal(signal.SIGALRM, handler)

def copytree(src, dst):
   names = os.listdir(src)
   os.makedirs(dst)
   signal.alarm(0)
   for name in names:
       if name in ignored_names:
           continue
       srcname = os.path.join(src, name)
       dstname = os.path.join(dst, name)
       try:
           if os.path.isdir(srcname):
               copytree(srcname, dstname, symlinks, ignore)
           else:
               signal.alarm(300)
               shutil.copy2(srcname, dstname)
       except (IOError, os.error), why:
           print str(why)
       # catch the Error from the recursive copytree so that we can
       # continue with other files
       except Error, err:
           print str(err.args[0])

source = "c:\\testwa\\"
destination = "d:\\testwa\\"

copytree(source,destination)

Then I re-read the documentation which said that signal.SIGALRM is unix/linux only. How do I go about doing this in windows?
Thanks for any help.
Cheers
Astan


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to