xbmcvfs.translatePath not working in Android
#31
easy way to find out if it's sqlite or permissions - write to a generic text file

db_writeout = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), PLUGIN_NAME, 'writeout.txt')
with open(db_writeout, 'w') as f:
    f.write('permission granted')


i personally dont see there being permission issues as kodi is usually granted all permissions to addon_data, being a child of it's userdata folder
Reply
#32
(2023-07-20, 16:33)jepsizofye Wrote: easy way to find out if it's sqlite or permissions - write to a generic text file

db_writeout = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), PLUGIN_NAME, 'writeout.txt')
with open(db_writeout, 'w') as f:
    f.write('permission granted')


i personally dont see there being permission issues as kodi is usually granted all permissions to addon_data, being a child of it's userdata folder

Good point on testing the folder permissions question.  I was thinking the same.  There are 3 main things which will cause an "unable to open database file" error:

1.  Wrong db file name
2. Folder permissions
3. DB file opened / locked by another process


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#33
(2023-07-20, 16:55)jbinkley60 Wrote: 1.  Wrong db file name
2. Folder permissions
3. DB file opened / locked by another process

4. db file has not been created yet / does not exist
Reply
#34
(2023-07-20, 17:00)jepsizofye Wrote: 4. db file has not been created yet / does not exist

No, actually SQLite will create the db file if it doesn't exist during the initial db.connect call.  This is both a blessing and a curse at times.  Without seeing the full code one concern I am seeing is continually opening the db file and creating cursors but never deleting the cursors or closing the file.  This can cause locking contention.  I typically have a single function which opens the file and then pass the connection handle to other functions and close at the end.  This is for speed since there is a tax on opening the file.  If  this is not a heavy database laden addon then explicitly opening, creating the cursor, deleting the cursor and closing the db file is recommended.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#35
I granted kodi full permissions 'allow all the time' in (Nvidia Shield) Android. This is What I got after last code test:
 2023-07-20 12:51:52.029 T:15091   error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'FileNotFoundError'>
                                                   Error Contents: [Errno 2] No such file or directory: '/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/userdata/addon_data/plugin.video.rtd/writeout.txt'
                                                   Traceback (most recent call last):
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.rtd/addon.py", line 70, in <module>
                                                       with open(db_writeout, 'w') as f:
                                                            ^^^^^^^^^^^^^^^^^^^^^^
                                                   FileNotFoundError: [Errno 2] No such file or directory: '/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/userdata/addon_data/plugin.video.rtd/writeout.txt'
                                                   -->End of Python script error report<--
Reply
#36
lets eliminate 1 more thing, in case kodi has not created the addon_data/plugin.video.rtd folder yet

db_writeout = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), 'writeout.txt')

-----

a better solution may be mkdirs

import xbmcvfs
xbmcvfs.mkdirs(os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), PLUGIN_NAME))

so you always know the folder exists

reference - https://romanvm.github.io/Kodistubs/_aut...mcvfs.html
Reply
#37
(2023-07-20, 19:15)jepsizofye Wrote: lets eliminate 1 more thing, in case kodi has not created the addon_data/plugin.video.rtd folder yet

The folder 'plugin.video.rtd' is not been created within this process yet.

So the intent is to create the folder even when in other platforms it is automatically created?
In fact in OSX, Also besides the db files I can see 'settings.xml' has been created within that folder too
Reply
#38
(2023-07-20, 19:26)lpence Wrote:
(2023-07-20, 19:15)jepsizofye Wrote: lets eliminate 1 more thing, in case kodi has not created the addon_data/plugin.video.rtd folder yet

The folder 'plugin.video.rtd' is not been created within this process yet.

So the intent is to create the folder even when in other platforms it is automatically created?
In fact in OSX, Also besides the db files I can see 'settings.xml' has been created within that folder too

no platform will allow you to create files in a folder that does not exist, if android is not creating it before you want to access files in it then you need to create it

do an if clause to make sure it exists with xbmcvfs.exists - https://romanvm.github.io/Kodistubs/_aut...vfs.exists

db_path = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), PLUGIN_NAME)
if not xbmcvfs.exists(db_path):
    xbmcvfs.mkdirs(db_path)
db_films = os.path.join(db_path, db_films_name)
Reply
#39
(2023-07-20, 19:43)jepsizofye Wrote:
(2023-07-20, 19:26)lpence Wrote:
(2023-07-20, 19:15)jepsizofye Wrote: lets eliminate 1 more thing, in case kodi has not created the addon_data/plugin.video.rtd folder yet

The folder 'plugin.video.rtd' is not been created within this process yet.

So the intent is to create the folder even when in other platforms it is automatically created?
In fact in OSX, Also besides the db files I can see 'settings.xml' has been created within that folder too

no platform will allow you to create files in a folder that does not exist, if android is not creating it before you want to access files in it then you need to create it

do an if clause to make sure it exists with xbmcvfs.exists - https://romanvm.github.io/Kodistubs/_aut...vfs.exists

db_path = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), PLUGIN_NAME)
if not xbmcvfs.exists(db_path):
    xbmcvfs.mkdirs(db_path)
db_films = os.path.join(db_path, db_films_name)

Kodi should create the addon_data/plugin.video.rtd/ sub folder for the addon upon installation time since that is where the settings.xml file lives.  Now if the addon has never been installed then it won't exist.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#40
(2023-07-20, 19:54)jbinkley60 Wrote: Kodi should create the addon_data/plugin.video.rtd/

absolutely, should

right now im working on (remotely) figuring out why a simple text file could not be created throwing an error "No such file or directory" - if it were permission, it should say so


if i had physical access i would simply adb shell into the box and verify all this, might even 'touch' some files and ls -la to see all the permissions ... but im here not there
Reply
#41
(2023-07-20, 19:43)jepsizofye Wrote: do an if clause to make sure it exists with xbmcvfs.exists - https://romanvm.github.io/Kodistubs/_aut...vfs.exists

db_path = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/"), PLUGIN_NAME)
if not xbmcvfs.exists(db_path):
    xbmcvfs.mkdirs(db_path)
db_films = os.path.join(db_path, db_films_name)
Thanks for your help. I have learned a lot!.

I added the code. After creating the folder it works, however the player stalls right after I stop the video and I end up with a frozen screen having to reboot!
Reply
#42
(2023-07-20, 20:17)lpence Wrote: Thanks for your help. I have learned a lot!.

youre welcome
 
(2023-07-20, 20:17)lpence Wrote: however the player stalls right after I stop the video and I end up with a frozen screen having to reboot!

that should be unrelated to accessing paths and should be assessed as a new issue
Reply
#43
Just after I though I was at the end of the tunnel.... Other do I need to open a different thread?
This is what I get anyways:

2023-07-20 14:07:59.000 T:7506    debug <general>: ------ Window Deinit (DialogBusy.xml) ------
2023-07-20 14:07:59.002 T:7506    error <general>: CGUIMediaWindow::GetDirectory(plugin://plugin.video.rtd/?film=Donbass%20Volunteers%3a%20United%20Strength) failed
2023-07-20 14:07:59.002 T:7506    debug <general>: CGUIMediaWindow::GetDirectory (plugin://plugin.video.rtd/?category=Films)
2023-07-20 14:07:59.002 T:7506    debug <general>:   ParentPath = [plugin://plugin.video.rtd/]
2023-07-20 14:07:59.004 T:7506    debug <general>: Loading items: 9, directory: plugin://plugin.video.rtd/?category=Films sort method: 0, ascending: false
2023-07-20 14:07:59.005 T:7598    debug <general>: CAddonDatabase::SetLastUsed[plugin.video.rtd] took 3 ms
2023-07-20 14:07:59.009 T:7649    debug <general>: Thread BackgroundLoader start, auto delete: false
2023-07-20 14:07:59.015 T:7649    debug <general>: Thread BackgroundLoader 169146809536 terminating
2023-07-20 14:07:59.020 T:7506    debug <general>: CVideoGUIInfo::InitCurrentItem(https://cdnv.russiatoday.com/rtd-files/f...ngth_2.mp4)
2023-07-20 14:07:59.033 T:7506    debug <general>: CPlayerGUIInfo::InitCurrentItem(https://cdnv.russiatoday.com/rtd-files/f...ngth_2.mp4)
2023-07-20 14:07:59.042 T:7509    debug <general>: void CXBMCApp::OnPlayBackStarted()
2023-07-20 14:07:59.050 T:7509    debug <general>: Visible Behind request: false
2023-07-20 14:07:59.133 T:7506    debug <general>: ------ Window Init (DialogBusy.xml) ------
Reply
#44
(2023-07-20, 20:17)lpence Wrote: Thanks for your help. I have learned a lot!.

I added the code. After creating the folder it works, however the player stalls right after I stop the video and I end up with a frozen screen having to reboot!

Out of curiosity, did the addon go through an installation process at some point ? And does it have a settings.xml file in the addon ?


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#45
(2023-07-20, 20:58)jbinkley60 Wrote: Out of curiosity, did the addon go through an installation process at some point ? And does it have a settings.xml file in the addon ?


Jeff

Yes, I installed zip file normally but it never created the folder in Android. The settings file shows up inside the folder and addon works flawlessly in other platforms
Reply

Logout Mark Read Team Forum Stats Members Help
xbmcvfs.translatePath not working in Android0