[Pythonmac-SIG] macostools.copytree() problems...

jlegg@acs.wooster.edu jlegg@acs.wooster.edu
Fri, 15 Jun 2001 08:27:38 -0400 (EDT)


 I'm working on a python program to do automatic backups of specific
folders/files to a Novell server. I'm using macostools.copytree() to do
the actual file copying but I'm having a very hard time. Why, when I do:
 s = 'System:System Folder'
 d = 'NOVELL_SERVER:Home:User:Whatever'
 macostools.copytree(s, d)

Everything works fine, all files copy and folder structure is recreated.

However, I want to add extensibility to my program by being able to read
in a list of folders/files to backup from a file. I do:
 f=open('backuplist', 'r+')
 str_list = f.readlines()
 backup_folder = 'NOVELL_SERVER:Home:User:Whatever'
 
 for s in str_list:
     s = re.sub('\n', '', s)
     if os.path.isdir(s):
	d = backup_folder + ':' + s
        # The above is just to recreate my HDD folder structure
        macostools.copytree(s, d)

This does not work on any mac I've tried it on. I've suspected it may have
something to do with the way I get rid of '\n' from each line in the file,
or maybe that I'm missing some other special characters that are causing
weird behaviors? Or perhaps my re.sub() is adding something?
The error I get is as follows:
  File "system:applications:python 2.1:mac:lib:macostools.py", line 126,
in copytree
    copy(src, dst, 1, copydates)
  File "system:applications:python 2.1:mac:lib:macostools.py", line 107,
in copy
    df = dstfss.GetFInfo()
Mac OS Error: (-43, 'File not found')

It does not matter if I use different folders, adding ':' to the end of my
folder names, etc. I've tried each and with the same results. copytree()
does crash when it encounters a broken alias with this similar message but
I am sure this is not the case here. I've also on occasion observed this
same message with a file name, the first file in the folder I was trying
to copy, and it was a *file* called 'Adobe Prefs' but the error message
produced 'Adobe Prefs:' ?? 

Anyone have ideas?