os.remove() on Windows 7
#1
In my iPhoto plugin, when the user imports the library, it creates a temporary file first, removes the original file, and renames the temp file to the original.

Using XBMC Dharma beta 3 under WINE on my Linux box, this works:

os.remove(xbmc.translatePath(os.path.join(addon.getAddonInfo("Profile"), "iphoto.db")))

However, on a real Windows 7 machine, it silently fails. No exception is thrown, but the file does not get removed.

Any ideas?

-jingai
Reply
#2
jingai Wrote:In my iPhoto plugin, when the user imports the library,
os.remove(xbmc.translatePath(os.path.join(addon.getAddonInfo("Profile"), "iphoto.db")))

hi,
not sure, but test os.unlink( ... )
or check if addon is not connected on file iphoto.db, if connected, disconnect addon of db and remove

frost
For my bad English, sorry. I am French Canadian.
Admin @ Passion-XBMC.org
Reply
#3
FrostBox Wrote:hi,
not sure, but test os.unlink( ... )

I did that, actually. Same result: no exception thrown, but file still exists.

Quote:or check if addon is not connected on file iphoto.db, if connected, disconnect addon of db and remove

Nothing has the file open. When a process does have it open, Windows correctly throws an exception to indicate that (have tested it).

-j
Reply
#4
Are you tested FileDelete(filename) of httpapi

PHP Code:
print xbmc.executehttpapi("FileDelete(%s)" os.path.join(addon.getAddonInfo("Profile"), "iphoto.db")) 
or maybe with shutil.move to windows tempdir
PHP Code:
import shutil
from tempfile import gettempdir
shutil
.movesourceos.path.join(gettempdir(), "iphoto.db") ) 
For my bad English, sorry. I am French Canadian.
Admin @ Passion-XBMC.org
Reply
#5
FrostBox Wrote:Are you tested FileDelete(filename) of httpapi

PHP Code:
print xbmc.executehttpapi("FileDelete(%s)" os.path.join(addon.getAddonInfo("Profile"), "iphoto.db")) 

This didn't work either. Further investigation reveals that somehow the process still had the database file open, even after deleting the pysqlite2 object.

I got sick of dealing with it and just update it in place now..

Thanks for the help,
-jingai
Reply

Logout Mark Read Team Forum Stats Members Help
os.remove() on Windows 70