Hello,
I am trying to set up debugging of Kodi addons using Eclipse + PyDev.
The problem I have is that the FIRST time the addon is run it works fine: the debugger breaks on the line after the pydevd.settrace() call, and I can step through the Python code.
At any subsequent runs an exception is thrown in PyDev and the addon exits.
I have set up debugging according to these articles:
1)
http://kodi.wiki/view/HOW-TO:Debug_Pytho...th_Eclipse
2)
https://www.youtube.com/watch?v=pWGaLl87xXk
Setup:
Windows 10 / Kodi 16.1 / Eclipse 4.5.2 / PyDev 4.5
Addon: YouTube addon (other addons same story)
PyDev exception: 'RuntimeError: classes are read-only in restricted mode' in pydevd_tracing.py line 77
The basic setup seems OK (otherwise it would not break at all in Eclipse).
I suspect the problem has to do with the fact that each time the addon runs on a different thread in Kodi.
I tried settrace(..., trace_only_current_thread=False) (see
http://devlvl99.blogspot.nl/2014/01/debu...pydev.html), but that did not help.
The same problem occurs if I debug using VS2013 and 'Python Tools for Visual Studio': at the first addon run it breaks into the VS debugger, but at subsequent runs it does not.
Any ideas?
Kodi newbie...
No replies so far...
I find it hard to believe that I am the only one with the problem described above. I have set up Python add-on debugging completely according to the existing documentation, using the newest versions of all software involved.
Can at least somebody tell me that they have debugging working correctly using the software versions mentioned above? Or is add-on debugging under Windows so rarely done that I am virtually on my own?
Thanks.
I've got the impression that most addon developers don't use such advanced tools. Personally, I break my code into structural parts (modules) and try to write those parts in such way that they can be run and debugged in isolation. Unit testing also helps, though I have to admit that I'm more than often too lazy to write proper tests. And verbose debug logging, of course.
I got frustrated getting the debug/breakpoint thing to work.
I do my debugging by printing the variables to the log file.
I use a program that "tail -f' on the log file called
baretail
So I have response from PyDev creator Fabio Zadrozny:
Code:
I think the issue you're having is that the module you're using is using Python in restricted mode (https://docs.python.org/2/library/rexec.html)...
I don't think there's much that can be done in PyDev -- that functionality of Python itself seems to be deprecated (since 2.6 and removed in Python 3) and the debugger doesn't really support it (i.e.: apparently it's not even possible to set attributes in classes) -- I must say I'm really surprised it worked the first time given that there are probably lots of restrictions on restricted mode.
What you can try to do is changing the code locally to work around the issues it may have to see if you can get farther (i.e.: remove the .pyd files generated on folders below e:\Program Files\Brainwy\LiClipse 3.1.0\plugins\org.python.pydev_5.2.0.201608171655\pysrc\ and treat the exceptions you have in the .py files because of the restricted mode).
Cheers,
Fabio
How nice it would be if Kodi had python 3 support.
Is there any possibility to run Kodi with python not using restricted mode ?
Thanks for any clarification.
There is error log I encountered:
Code:
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: classes are read-only in restricted mode
Traceback (most recent call last):
File "C:\Users\decak\AppData\Roaming\Kodi\addons\plugin.video.sosac.ph\default.py", line 37, in <module>
pydevd.settrace('localhost', stdoutToServer=True, stderrToServer=True,trace_only_current_thread=False)
File "e:\Program Files\Brainwy\LiClipse 3.1.0\plugins\org.python.pydev_5.2.0.201608171655\pysrc\pydevd.py", line 1129, in settrace
patch_multiprocessing,
File "e:\Program Files\Brainwy\LiClipse 3.1.0\plugins\org.python.pydev_5.2.0.201608171655\pysrc\pydevd.py", line 1208, in _locked_settrace
debugger.patch_threads()
File "e:\Program Files\Brainwy\LiClipse 3.1.0\plugins\org.python.pydev_5.2.0.201608171655\pysrc\pydevd.py", line 845, in patch_threads
def patch_threads(self):
File "e:\Program Files\Brainwy\LiClipse 3.1.0\plugins\org.python.pydev_5.2.0.201608171655\pysrc\_pydevd_bundle\pydevd_trace_dispatch.py", line 23, in trace_dispatch
return _trace_dispatch(py_db, frame, event, arg)
File "_pydevd_bundle\pydevd_cython_win32_27_32.pyx", line 872, in _pydevd_bundle.pydevd_cython_win32_27_32.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_27_32.c:14458)
File "e:\Program Files\Brainwy\LiClipse 3.1.0\plugins\org.python.pydev_5.2.0.201608171655\pysrc\pydevd_tracing.py", line 77, in SetTrace
TracingFunctionHolder._warn = False #zbyna
RuntimeError: classes are read-only in restricted mode
-->End of Python script error report<--
(2016-09-01, 20:46)gedisony Wrote: [ -> ]I got frustrated getting the debug/breakpoint thing to work.
I do my debugging by printing the variables to the log file.
I use a program that "tail -f' on the log file called baretail
Indeed a lot of frustration ...
I have tried to modify
I am able to continue in debugging BUT I am able only to catch log from addon
not variable, breakpoints and other stuff.
Thanks for tip:
https://www.baremetalsoft.com/baretail/
Remote debugging works like a charm including breakpoints:
Code:
win7 64bit.
LiClipse 3.1.0.20160817
PyDev for Eclipse 5.2.0.20160817
Kodi (16.1 Git:20160424-c327c53)
+
nabilbendafi/script.module.pydevd https://github.com/nabilbendafi/script.module.pydevd
Finally
BTW, I've also tried
remote debugging in Python Tools for Visual Studio and it works, although not very smooth: both Kodi and Visual Studio freezes periodically during debugging. But it works, including breakpoints and displaying variable values. Naturally, you need to add
ptvsd module to your addon somehow.
Hy Roman,
could you please post how you configured Eclipse to get debugging working?
I tried to do that according to wiki page but it needs to be updated as os, kodi , python versions have changed since the first publication of the web page.
In particularly paths are changed.
I'm a newbie on kodi and python programming and I would like to setup Windows 10 (and mac osx), Eclipse Neon with Python 2.7 for debugging.
Thanks in advance for your kind reply.
Best
(2016-09-04, 16:24)Roman_V_M Wrote: [ -> ]True Python hackers can now use Python's built-in PDB debugger: https://github.com/romanvm/kodi.remote-pdb
Hy Roman,
could you please post how you configured Eclipse to get debugging working?
I tried to do that according to wiki page but it needs to be updated as os, kodi , python versions have changed since the first publication of the web page.
In particularly paths are changed.
I'm a newbie on kodi and python programming and I would like to setup Windows 10 (and mac osx), Eclipse Neon with Python 2.7 for debugging.
Thanks in advance for your kind reply.
Best
P.S.: Couldn't cancel my previous post. Sorry to all.
(2016-10-17, 11:46)m.lombardo Wrote: [ -> ]Hy Roman,
could you please post how you configured Eclipse to get debugging working?
Please read my posts carefully. I've never written anything about Eclipse because I don't use it and prefer PyCharm. In fact, after trying several options I have developed my own debugger that is not tied to any IDE. More info is here:
http://forum.kodi.tv/showthread.php?tid=292141
(2016-10-17, 13:16)Roman_V_M Wrote: [ -> ] (2016-10-17, 11:46)m.lombardo Wrote: [ -> ]Hy Roman,
could you please post how you configured Eclipse to get debugging working?
Please read my posts carefully. I've never written anything about Eclipse because I don't use it and prefer PyCharm. In fact, after trying several options I have developed my own debugger that is not tied to any IDE. More info is here: http://forum.kodi.tv/showthread.php?tid=292141
First of all thank you very much for your quick reply.
I'm sorry if I supposed in my question you experienced debugging Kodi addons on Eclipse. I read carefully your posts and you are absolutely right: you never said so. Sorry.
In the same time I want to say: Thank you very much for your kind support. I'm going to read all the instructions concerning your debugger that seems a great solution for my target: learning kodi addon programming, debugging ready made addons.
Thank you very much for all. I appreciated your reply.
Best.