script.toolbox icon indicating copy to clipboard operation
script.toolbox copied to clipboard

Kodi Nexus v20 on TvOS - Error: module 'xbmc' has no attribute 'translatePath'

Open eengert opened this issue 3 years ago • 4 comments

Testing Kodi Nexus v20 Alpha on Apple TV 4K (2021) and script.toolbox does not work. It causes the error shown below from log. I found a similar sounding issue here that may help: https://forum.libreelec.tv/thread/24883-official-francetv-add-on-bug-in-le11-nightly-attributeerror-module-xbmc-has-no-a/.

If you think this actually an issue with the Kodi Alpha, please let me know so I can open this issue there for the Kodi devs. Thanks.

2022-06-18 08:19:56.440 T:2349185 ERROR : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <class 'AttributeError'> Error Contents: module 'xbmc' has no attribute 'translatePath' Traceback (most recent call last): File "/private/var/mobile/Containers/Data/Application/5CB2D904-DD77-4357-9320-FFD0C0D02C0D/Library/Caches/Kodi/addons/script.toolbox/default.py", line 6, in from resources.lib.Utils import * File "/private/var/mobile/Containers/Data/Application/5CB2D904-DD77-4357-9320-FFD0C0D02C0D/Library/Caches/Kodi/addons/script.toolbox/resources/lib/Utils.py", line 16, in ADDON_DATA_PATH = os.path.join(xbmc.translatePath("special://profile/addon_data/%s" % ADDON_ID)) AttributeError: module 'xbmc' has no attribute 'translatePath' -->End of Python script error report<--

eengert avatar Jun 18 '22 13:06 eengert

xbmc.TranslatedPath was fully deprecated in v20. xbmcvfs.TranslatePath should be used instead.

https://github.com/jojobrogess/script.toolbox/commits/master

I made this for myself a little while back so that I could get it to work. I'm pretty sure phil65 has retired from the kodi scene.

jojobrogess avatar Jan 14 '23 14:01 jojobrogess

Thanks, but this doesn't seem to install on Nexus since it depends on Python 2.1. My issue is specifically with Nexus, which runs on Python 3.

eengert avatar Jan 14 '23 15:01 eengert

I literally just installed tool.box without needing to do this but:

Inside addon.xml, you'll see:

<addon id="script.toolbox" name="ToolBox Script" version="1.1.3" provider-name="phil65">
	<requires>
		<import addon="xbmc.python" version="2.1.0"/>
		<import addon="script.module.simplejson" version="2.0.10"/>
		<import addon="script.module.pil" version="1.1.7"/>

Where it says: <import addon="xbmc.python" version="2.1.0"/> change it to <import addon="xbmc.python" version="3.0.0"/>

I just made the change on my repo, it should work now. https://github.com/jojobrogess/script.toolbox

LMK

jojobrogess avatar Jan 14 '23 23:01 jojobrogess

EDIT script.toolbox\resources\lib\Utils.py and ADD this:

try:
    translatePath = xbmcvfs.translatePath
except:
    translatePath = xbmc.translatePath

Right below:

import xbmc
import xbmcaddon
import xbmcgui
import xbmcvfs
import os
import json
import hashlib
import urllib
from PIL import Image, ImageOps
from resources.lib.ImageOperations import MyGaussianBlur
from xml.dom.minidom import parse

Then CHANGE the ADDON_DATA_PATH = to: ADDON_DATA_PATH = os.path.join(translatePath("special://profile/addon_data/%s" % ADDON_ID))

Pharaoh2k avatar Feb 19 '23 03:02 Pharaoh2k