I’ve got some code that copies a file from my application directory to a user’s home directory using shutil.copy():
if base.appRunner:
self.appFolder = base.appRunner.multifileRoot
else:
self.appFolder = os.path.dirname(__file__)
self.dataFolder = os.path.join(Filename.getHomeDirectory().toOsSpecific(), 'Library', 'Application Support', 'BOT')
self.sourceFile = os.path.join(self.appFolder, 'models.zip')
self.destFile = os.path.join(self.dataFolder, 'models.zip')
shutil.copy(self.sourceFile, self.destFile)
When I run using python, everything works, but when the application is packaged in a p3d it gives an IOError:
Traceback (most recent call last):
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
File "VFSImporter", line 153, in load_module
File "/Users/aaron/Projects/MAW/BOT/BOTApps/test/ziptest.py", line 67, in <module>
app = MyApp()
File "/Users/aaron/Projects/MAW/BOT/BOTApps/test/ziptest.py", line 27, in __init__
shutil.copy(self.sourceFile, self.destFile)
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/shutil.py", line 88, in copy
File "/Users/rdb/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/shutil.py", line 52, in copyfile
File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/stdpy/file.py", line 132, in __init__
IOError
:TaskManager: TaskManager.destroy()
:display: Closing osxGraphicsWindow
Successfully joined thread: 0
Failure on startup.
I’m assuming that this is an issue with copying a file from the virtual file system (reported as /mf on my machine). Is there a preferred panda method for copying files from the vfs?