OS X Reloading python add-on code and debugging it
#1
Question 
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.
Reply
#2
If the addon is not a service, it should reload the code on every run.
Reply
#3
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_pytho...ith_WinPDB
Reply
#4
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?
Reply
#5
(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_pytho...ith_WinPDB

No, thanks for the suggestion. Does it work even with services?
Reply
#6
There was a way to restart the service through JSON, here it is:

248758 (thread)
Reply
#7
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.
Reply

Logout Mark Read Team Forum Stats Members Help
Reloading python add-on code and debugging it0