[Pythonmac-SIG] macostools copy function broken in MachoPython build?

Kevin Altis altis@semi-retired.com
Mon, 29 Jul 2002 14:51:09 -0700


A friend of mine wanted to start using Python and as his first program he
wanted to be able to do a recursive backup of a directory of files to
another volume. Since he's on a Mac that means using the copy or copytree
functions in order to get the data and resource fork and Finder info.

http://www.python.org/doc/current/mac/module-macostools.html

However, he's trying to do this on Mac OS X, so I had him go get
MachoPython-2.2.1-4.dmg from the wxPython distribution:

http://sourceforge.net/project/showfiles.php?group_id=10718&release_id=56880

When we tried using copy function a file not found error was thrown for the
destination file. If you go ahead and create a dummy file, the copy still
seems to fail, though no errors are thrown. The actual message is:

MacOS.Error: (-43, 'File not found')

My friend installed MacPython on OS 9 and macostools.copy seemed to work
there, though of course the path is done with ':' instead of '/'. Any ideas
what we're doing wrong or is this a MachoPython macostools bug? Perhaps this
is just a problem with how Robin did the 2.2.1-4 build?

I've included some playing around I did in the shell under Mac OS X that
shows the error. Sorry about the email line wrapping.

ka
---
Kevin Altis
altis@semi-retired.com

---

 >>> import os
 >>> import macostools
 >>> os.getcwd()
'/Users/altis/python/PythonCardPrototype/samples/minimal'
 >>> filename = 'readme.txt'
 >>> path = os.path.join(os.getcwd(), filename)
 >>> path
'/Users/altis/python/PythonCardPrototype/samples/minimal/readme.txt'
 >>> os.path.exists(path)
1
 >>> macostools.copy(path, path + '2')
Traceback (most recent call last):
   File "<input>", line 1, in ?
   File
"/Library/Frameworks/Python.framework/Versions/2.2/Mac/Lib/macostools.py",
line 88, in copy
     dstfss = macfs.FSSpec(dst)
MacOS.Error: (-43, 'File not found')
 >>> macostools.macfs
<module 'macfs' from
'/Library/Frameworks/Python.framework/Versions/2.2/lib/python2.2/lib-dynload
/macfs.so'>
 >>> macostools.macfs.FSSpec(path)
FSSpec((-100, 141127, 'readme.txt'))
 >>> macostools.macfs.FSSpec(path + '1')
Traceback (most recent call last):
   File "<input>", line 1, in ?
MacOS.Error: (-43, 'File not found')