Kodi Community Forum
OS X Reloading python add-on code and debugging it - 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: OS X Reloading python add-on code and debugging it (/showthread.php?tid=313882)



Reloading python add-on code and debugging it - falcon03 - 2017-05-07

Hi all,

my python knowledge is not so advanced and I am new to Kodi add-on development. I wonder wether it would be possible to get a couple of features to speed up the development process: code reload and debugging.

For the first point, I'd like the code of my add-on to be reloaded after I edit it without having to restart Kodi manually every time. As anyone found an easy way to accomplish that?

Regarding the second point, I'd like to attach a debugger to Kodi so that I can get error messages and/or warnings more easilyand have a closer look at the situation when things don't go as you expect. Is there any way to do that?

I know that both things can be done by using Eclipse and Pydev, but unfortunately that's not an option for me. Any alternatives?

Thanks in advance for your support.


RE: Reloading python add-on code and debugging it - User 325245 - 2017-05-07

If the addon is not a service, it should reload the code on every run.


RE: Reloading python add-on code and debugging it - Mike321 - 2017-05-07

The python code is reloaded on every run. You can see the exceptions and other messages in the log file.
Keep in mind that if you do changes in addon.xml, or other non python files, you have to restart kodi.

For the debug part, have you tried WinPDB?
http://kodi.wiki/view/HOW-TO:Debug_python_scripts_with_WinPDB


RE: Reloading python add-on code and debugging it - falcon03 - 2017-05-07

Hi @DaLanik,

thanks for your reply. I am working on a service, so Kodi loads its code only at startup. Any way to reload the code in this case as well?


RE: Reloading python add-on code and debugging it - falcon03 - 2017-05-07

(2017-05-07, 12:52)Mike321 Wrote: The python code is reloaded on every run. You can see the exceptions and other messages in the log file.
Keep in mind that if you do changes in addon.xml, or other non python files, you have to restart kodi.

Thanks for clarifying that. However the add-on I am working on is (and needs to be) a service. I think that the code of a service is loaded *only* during Kodi startup: am I right? If so, is there any way to reload the code after changing it without restarting Kodi? Or perhaps a mechanism to restart Kodi automatically after changing the service code?


(2017-05-07, 12:52)Mike321 Wrote: For the debug part, have you tried WinPDB?
http://kodi.wiki/view/HOW-TO:Debug_python_scripts_with_WinPDB

No, thanks for the suggestion. Does it work even with services?


RE: Reloading python add-on code and debugging it - User 325245 - 2017-05-07

There was a way to restart the service through JSON, here it is:

248758 (thread)


RE: Reloading python add-on code and debugging it - Roman_V_M - 2017-05-07

A bit of self-promotion but I hope nobody minds Smile
https://github.com/romanvm/kodi.web-pdb

As for reloading your code, PDB can restart the script under the debugger control, but I don't know if it re-reads the source or re-uses already compiled in-memory bytecode.