xbmcvfs.delete() can't find file to delete - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: xbmcvfs.delete() can't find file to delete (/showthread.php?tid=195108) |
xbmcvfs.delete() can't find file to delete - yosubis - 2014-05-14 I tried calling xbmcvfs.delete with the path to the file and with a file object but neither works. It worked in Frodo, but no go in Gotham. Also, the Frodo python docs have a description for this: http://mirrors.xbmc.org/docs/python-docs/12.2-frodo/xbmcvfs.html#-delete But the Gotham python docs are missing it: http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/xbmcvfs.html#-delete Are there any suggestions as to how to delete a file in Gotham? RE: What happend to xbmcvfs.delete() in Gotham? - pkscout - 2014-05-14 A debug log would be helpful. I use xbmcvfs.delete() in Artist Slideshow, and it's working fine in Gotham. RE: What happend to xbmcvfs.delete() in Gotham? - yosubis - 2014-05-14 The code: Code: xbmc.log('User File: %s' % user_file) The log: Code: NOTICE: User File: C:\Users\---\AppData\Roaming\XBMC\userdata\addon_data\---\user_info.json It worked in Frodo. Updated to Gotham, and it stopped working. RE: What happend to xbmcvfs.delete() in Gotham? - Martijn - 2014-05-14 looks already wrong from the log message. no way that's gonna work like that RE: What happend to xbmcvfs.delete() in Gotham? - yosubis - 2014-05-14 What seems wrong? The dashes are not part of the original log, I placed them in the post (I'm a wee bit paranoid). I don't think the double slash are the cause since it is just a representation of a slash. Edit: Also, I know for a fact that the file exists. When I copy the file path that is reported as non existent and paste it in a run window, it opens the correct file. RE: What happend to xbmcvfs.delete() in Gotham? - yosubis - 2014-05-15 Can anyone enlighten me as to what I'm doing wrong? RE: What happend to xbmcvfs.delete() in Gotham? - giftie - 2014-05-16 I believe you need to get rid of the double backslashes and change them to single backslash... You Might try changing them to forward slashes(single) RE: What happend to xbmcvfs.delete() in Gotham? - pkscout - 2014-05-18 If you built the path by joining strings, that might be the problem. You might try using os.path.join. It would be really helpful to see more than two lines of code out of context and a little snippet of the log. RE: What happend to xbmcvfs.delete() in Gotham? - yosubis - 2014-06-03 A little more detailed code: Code: ADDON_DATA['addon'] = xbmcaddon.Addon() results in (replaced actual username and addon name because of my paranoid nature): Code: 11:18:09 T:1764 NOTICE: User File: C:\Users\USERNAME\AppData\Roaming\XBMC\userdata\addon_data\ADDON NAME\user_info.json RE: xbmcvfs.delete() can't find file to delete - yosubis - 2014-06-05 Something odd. If I have this: Code: os.remove(user_file) Nothing happens to the file and I get this (a xbmc notice): Code: NOTICE: [Errno 2] No such file or directory: u'C:\\Users\\USERNAME\\AppData\\Roaming\\XBMC\\userdata\\addon_data\\ADDON NAME\\user_info.json' But if I have this: Code: os.remove(user_file) The file is deleted and I get this (a python error): Code: WindowsError: [Error 2] The system cannot find the file specified: u'C:\\Users\\USERNAME\\AppData\\Roaming\\XBMC\\userdata\\addon_data\\ADDON NAME\\user_info.json' Any ideas? RE: xbmcvfs.delete() can't find file to delete - removed151214 - 2014-06-05 I'm no python expert, I'll be the first to admit, but the only line that stands out to me is (2014-06-03, 10:24)yosubis Wrote: user_file = os.path.join(ADDON_DATA['profile_dir'], USER_FILE_NAME) As someone quite happy to admit they don't get the whole encode/decode utf-8 thing, even after reading lots of docs, I thought that would have to be: Code: user_file = os.path.join(ADDON_DATA['profile_dir'].encode('utf-8'), USER_FILE_NAME).decode('utf-8') I'm going to assume that won't help, though, so will simply say - the error is quite clear: the file isn't found. That basically leaves you with two possibilities: either the file isn't where you think it is, or the path you're passing to xbmcvfs.delete isn't correct. RE: xbmcvfs.delete() can't find file to delete - yosubis - 2014-06-05 But that's the thing, the file does exist and python even knows it's there. It just won't delete that file. It will delete other files in the same folder, joined in the same way, but not these one. I tried this; Code: file_to_delete = os.path.join(ADDON_DATA['profile_dir'].encode('utf-8'), USER_FILE_NAME).decode('utf-8') And the log shows this: Code: 10:55:26 T:6456 NOTICE: User file exists, Prepairing to delete So the file is there. Python can find it except when trying to delete it. I have no idea why. RE: xbmcvfs.delete() can't find file to delete - yosubis - 2014-06-05 Ok, it seems I found the problem. I put "time.sleep(2)" after "os.remove(file_to_delete)" and then everything worked. |