[Solved] Python Debugging with external IDE

Keyboard macros or custom scripts
Post Reply
User avatar
devarni
Posts: 9
Joined: Tue Apr 09, 2013 9:35 am
Location: Berlin, Germany
Contact:

[Solved] Python Debugging with external IDE

Post by devarni »

Somebody knows if remote debbugging is working and how this must be setup with OO/LO to debug Python macros?
It's not the problem to use the OO/LO Python interpreter in IDEs like Pycharm but the most interesting thing would be to use the debbugging features of this IDEs.
Last edited by Hagar Delest on Wed Apr 10, 2013 12:20 pm, edited 1 time in total.
Reason: tagged [Solved].
Openoffice 4.0.2/Windows 8
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Python Debugging with external IDE

Post by hanya »

I do not know about PyCharm well but I have debugged my python macro with Eclipse + Pydev with the following line:

Code: Select all

import pydev.pydevd; pydev.pydevd.settrace()
It needs files from eclipse/plugins/org.python.pydev.pydev_xxx/pysrc, copy them in profile/Scripts/python/pythonpath/pydev and add __init__.py into it.
 Edit: pydev files can be found in plugins/org.python.pydev_VERSION.DATE/pysrc
With python3, importing from pythonpath/pydev has problem. Try something like:

Code: Select all

pydev_path = "PATH_TO/plugins/org.python.pydev_VERSION.DATE/pysrc"
import sys
if not pydev_path in sys.path:
    sys.path.append(pydev_path)
# ... to start and connect to remote debugging service
    import pydevd; pydevd.settrace()
 
Last edited by hanya on Wed Apr 10, 2013 8:29 am, edited 1 time in total.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
User avatar
devarni
Posts: 9
Joined: Tue Apr 09, 2013 9:35 am
Location: Berlin, Germany
Contact:

Re: Python Debugging with external IDE

Post by devarni »

hanya wrote:I do not know about PyCharm well but I have debugged my python macro with Eclipse + Pydev with the following line:

Code: Select all

import pydev.pydevd; pydev.pydevd.settrace()
It needs files from eclipse/plugins/org.python.pydev.pydev_xxx/pysrc, copy them in profile/Scripts/python/pythonpath/pydev and add __init__.py into it.
Some good hint! I remember pydev...

I got this working with pydev... Unfortunately introspection seems not to work "None: pyuno object" for XSpreadsheet etc. So it's not really usable. Have you got this working so it shows also this stuff?
Openoffice 4.0.2/Windows 8
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Python Debugging with external IDE

Post by hanya »

It seems PyCharm uses Pydev for remote debugging from its documentation but I'm not really sure.
Have you got this working so it shows also this stuff?
I did not notice it. But it might be caused by the incomplete implementation of the pyuno object.
Did you try it wih LibreOffice 4.0.X and Python 3.3? Its dir functionality is broken, if the introspection depends on it, it does not work with that.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
User avatar
devarni
Posts: 9
Joined: Tue Apr 09, 2013 9:35 am
Location: Berlin, Germany
Contact:

Re: Python Debugging with external IDE

Post by devarni »

I have not used a external Python installation from OO (Afaik this needs some bigger work to get it running) but I use Python 3.3.1 from Pydev and with the actual Libreoffice (4.0.2) with the same effect.
I have no idea if this is a bug or a incomplete implementation so the interfaces/properties etc. are not seen from the debugger inside Pydev.

Only for the introspection stuff Xray works fine but I'm more interested to have a full usable debugging environment. With Pydev is a good idea and it works very easy... but the problem with the "None: pyuno object" is still there :(
Openoffice 4.0.2/Windows 8
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Python Debugging with external IDE

Post by hanya »

I tested remote debugging by PyDev with python instance working inside AOO 4 dev and LO 4.0.1.2.
The introspection was worked with AOO4 but not with LO4.
Here is small hack for pydevd_resolver.py to be introspection working in DefaultResolver._getPyDictionary method:

Code: Select all

--- /home/asuka/.config/libreoffice/4/user/Scripts/python/pydev/pydevd_resolver.py	2013-04-10 15:15:35.775676524 +0900
+++ /mnt/hd/34/user/Scripts/python/pythonpath/pydev/pydevd_resolver.py	2013-03-15 22:39:24.000000000 +0900
@@ -162,8 +162,6 @@
         filterBuiltIn = True
 
         names = dir(var)
-        if not names and hasattr(var, "__members__"):
-            names = var.__members__
         d = {}
 
         #Be aware that the order in which the filters are applied attempts to
So, the problem is caused by lacking __dir__ function from pyuno object of LO.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
User avatar
devarni
Posts: 9
Joined: Tue Apr 09, 2013 9:35 am
Location: Berlin, Germany
Contact:

Re: Python Debugging with external IDE

Post by devarni »

:bravo:
Yeah, your hack is working! Hopefully this will be fixed very soon.
Openoffice 4.0.2/Windows 8
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] Python Debugging with external IDE

Post by hanya »

Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Post Reply