Bug 106215 - Debugging Python is hard and activating it needs editing essential files
Summary: Debugging Python is hard and activating it needs editing essential files
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevAdvice
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2017-02-27 11:26 UTC by jan d
Modified: 2020-04-25 12:54 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jan d 2017-02-27 11:26:25 UTC
Description:
Story: As a (beginning) Extension Developer I want to be able to inspect/debug existing extensions to find out how they work and also debug my own extensions. I would like to read log output and ideally attach a remote debugger.  



Steps to Reproduce:
After some searching, I was able to find that, for debugging, I need to change pythonscript.py to set LogLevel.use = LogLevel.DEBUG and also need to set the Environment variable PYUNO_LOGLEVEL=ARGS

(see https://wiki.openoffice.org/wiki/Python and http://ooo-forums.apache.org/en/forum/viewtopic.php?f=20&t=66276 ) 

Actual Results:  
After doing the changes I still could not get any debug output for my code. 
Remote debugging I did not try, however, it seemed to rely on custom code where I saw such (see: https://github.com/XRoemer/Organon/blob/master/source/py/factory.py#L51)

Expected Results:
1) An up-to-date guide to set the needed changes with some examples. Currently all needs to be collected at various places, some being rather old (openoffice-wiki etc.)
2) Better, I switch I can set via command line or even via the GUI that does needed changes for me, thus avoiding mistakes by interfaceing the needed settings. 



Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Comment 1 XTR 2017-12-06 10:51:23 UTC
Confirm  for  LO 6.0.0.0beta x64  Windows 7 

There is missing folders
to get needed log.txt:
1. Create folder C:\Users\%User%\AppData\Roaming\LibreOfficeDev\4\user\Scripts\python  or 
   %LibreofficeUSERDIR%/Scripts/python
  log.txt is created here
2. in file pythonscript.py  set
LogLevel.use = LogLevel.DEBUG
LOG_STDOUT = False

to fix:
in pythonscript.py:
1. check folder existence in   def getLogTarget():
2. LOG_STDOUT = os.environ.get(PYSCRIPT_LOG_STDOUT_ENV, "1") != "0"
   fix this to work well in windows environment
Comment 2 QA Administrators 2018-12-07 03:47:09 UTC Comment hidden (obsolete)
Comment 3 Roman Kuznetsov 2018-12-07 07:25:09 UTC
Xisco, please retest it
Comment 4 LibreOfficiant 2019-12-06 10:29:24 UTC
"Designing & Developing Python Applications" content in TDF wiki, and recent local/online help Python pages appearing from release 6.3, may partly invalidate Jan's original observations.

Remote debuggers can be attached to Python macros. LibO Python files need not be updated anymore, despite past statements in former documentation.

However Python, or other language, debugging may still sound "weird" when packed in an extension. I personnally don't foresee improvements with respect to extensions debugging, but I may be wrong.

https://wiki.documentfoundation.org/Macros/Python_Design_Guide
https://help.libreoffice.org/latest/en-US/text/sbasic/python/main0000.html?DbPAR=BASIC
Comment 5 Buovjaga 2020-04-24 16:30:58 UTC
Discussed the topic with LibreOfficiant and he was still of the opinion that the documentation situation is much better compared to 2017, so we can close.
Comment 6 jan d 2020-04-25 11:11:44 UTC
Dos the pythonscript.py file still need to be edited to activate debugging? (If yous, I would create a separate ticket on the editing files, so we do not need to treat documentation and the problems of activating debugging in the same ticket)
Comment 7 Buovjaga 2020-04-25 11:33:27 UTC
(In reply to jan d from comment #6)
> Dos the pythonscript.py file still need to be edited to activate debugging?
> (If yous, I would create a separate ticket on the editing files, so we do
> not need to treat documentation and the problems of activating debugging in
> the same ticket)

I don't see anything about that here, please check: https://wiki.documentfoundation.org/Macros/Python_Design_Guide#Debugging_2
Comment 8 Alain Romedenne 2020-04-25 12:54:00 UTC
I confirm that LibreOffice files do not need to be edited in order to debug a Python script.