Kodi Community Forum

Full Version: Add-on port to Python3 has error(s)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

please can someone help me make my add-on ready for Kodi 19?
I´m not capable at this moment to try to port it for python 3.
I do use this add-on with a SSD1306 OLED Display

this is my error message in the log

2021-01-24 20:08:35.871 T:782     ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'TabError'>
                                                   Error Contents: inconsistent use of tabs and spaces in indentation (main.py, line 166)
                                                     File "/storage/.kodi/addons/script.oled.xbmc/main.py", line 166
                                                       draw.rectangle((0,-4,width,height), outline=0, fill=0)
                                                                                                            ^
                                                   TabError: inconsistent use of tabs and spaces in indentation
                                                   -->End of Python script error report<--

thank you all very much.

My Add-on
Can you at least tell us what the addon is supposed to do? Throwing a chunk of code at us, and saying you are not "capable" of doing Python 3, sounds like you want us to do your homework.
(2021-01-24, 21:46)Klojum Wrote: [ -> ]Can you at least tell us what the addon is supposed to do? Throwing a chunk of code at us, and saying you are not "capable" of doing Python 3, sounds like you want us to do your homework.

 all right thanks 4 a reply I do my best to explain it. It is a simple Python script to show infos grabbed from Kodi on an 0.96 inch OLED Display through I2C. so while live-tv is on it shows a logo of the Channel/or Channel number. I think the Problem is not in my script as such but more in the driver.

My problem is that I´m not skilled enough to figure out the problem. 

And please, it is not that I try to push anyone to do my "homework" I do have MS based mental issues that got bigger at the moment so how hard I tried over the past 3 years since I wrote my script (I took me 4 month) I´m not been able to understand python so I can not fix the problem. So sorry if I bothered you.
The error is probably exactly what was reported:  Leading whitespace on lines is significant in Python.   Use an editor that can show you whitespace characters and I suspect you will find on line 166 there is a "tab" character, when you probably need to replace it with 4 "space" characters (or how ever many characters you have your tab set to).

scotrt s.
.
(2021-02-02, 01:50)scott967 Wrote: [ -> ]The error is probably exactly what was reported:  Leading whitespace on lines is significant in Python.   Use an editor that can show you whitespace characters and I suspect you will find on line 166 there is a "tab" character, when you probably need to replace it with 4 "space" characters (or how ever many characters you have your tab set to).

scotrt s.
.

THX Scott, well yes Python is a bitch. I cleaned my code. I do get this error now.

EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: Error Contents: No module named 'Adafruit_BBIO' Traceback (most recent call last): File "/storage/.kodi/addons/script.oled.xbmc/main.py", line 67, in disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C) File "/storage/.kodi/addons/script.oled.xbmc/lib/Adafruit_SSD1306/SSD1306.py", line 242, in __init__ super(SSD1306_128_64, self).__init__(128, 64, rst, dc, sclk, din, cs, File "/storage/.kodi/addons/script.oled.xbmc/lib/Adafruit_SSD1306/SSD1306.py", line 85, in __init__ self._gpio = GPIO.get_platform_gpio() File "/storage/.kodi/addons/script.oled.xbmc/lib/Adafruit_GPIO/GPIO.py", line 420, in get_platform_gpio import Adafruit_BBIO.GPIO ModuleNotFoundError: No module named 'Adafruit_BBIO' -->End of Python script error report<--



ihm sure this is because the driver as such is no longer python 3 compatible. I did use the libs from the official LibreELEC virtual.adafruit.libraries.
does anyone have an idea?
This would be better in the addons development section - moving it there.
(2021-02-02, 21:35)tjost Wrote: [ -> ]EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: Error Contents: No module named 'Adafruit_BBIO' Traceback (most recent call last): File "/storage/.kodi/addons/script.oled.xbmc/main.py", line 67, in disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C) File "/storage/.kodi/addons/script.oled.xbmc/lib/Adafruit_SSD1306/SSD1306.py", line 242, in __init__ super(SSD1306_128_64, self).__init__(128, 64, rst, dc, sclk, din, cs, File "/storage/.kodi/addons/script.oled.xbmc/lib/Adafruit_SSD1306/SSD1306.py", line 85, in __init__ self._gpio = GPIO.get_platform_gpio() File "/storage/.kodi/addons/script.oled.xbmc/lib/Adafruit_GPIO/GPIO.py", line 420, in get_platform_gpio import Adafruit_BBIO.GPIO ModuleNotFoundError: No module named 'Adafruit_BBIO' -->End of Python script error report<--



ihm sure this is because the driver as such is no longer python 3 compatible. I did use the libs from the official LibreELEC virtual.adafruit.libraries.
does anyone have an idea?

Well, that looks like a typical import error, since importing was changed between Python 2 and 3. I admit I have not been able to easily fix import errors, but the first thing is make sure the path to the .py file (module) is known when running in Kodi. When Kodi runs your addon, a debug log will show all the paths Kodi will look in to find the module file.

scott s.
.
is there anyone who can implement this as an add-on in Kodi?
I couldn't even find the addon sources where is it? Also we have lcdproc addon in the repo, isn't that the same as script.oled.xbmc ?
(2021-02-07, 13:48)enen92 Wrote: [ -> ]I couldn't even find the addon sources where is it? Also we have lcdproc addon in the repo, isn't that the same as script.oled.xbmc ?

there no official oled add-on as I mentioned I done it my self