Description: officehelper.py module bootstrap() function does not connect or connects with annoying msgbox(es) that state that LibreOffice/soffice can't be found. Works fine with 5.2.3 Steps to Reproduce: 1. Open LibreOffice Python interpreter 2. type " import officehelper as oh " 3. type " oh.bootstrap() " Actual Results: Python 3.5.4 (default, Jan 30 2018, 19:34:57) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import officehelper as oh >>> oh.bootstrap() Traceback (most recent call last): File "C:\Program Files\LibreOffice 5\program\officehelper.py", line 72, in bootstrap xContext = resolver.resolve(sConnect) uno.NoConnectException: Connector : couldn't connect to pipe uno5434955891389311(1) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\LibreOffice 5\program\officehelper.py", line 77, in bootstrap raise BootstrapException("Cannot connect to soffice server.", None) officehelper.BootstrapException: Cannot connect to soffice server. Expected Results: Python 3.5.4 (default, Feb 8 2018, 19:35:03) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.>>> import officehelper as oh >>> oh.bootstrap() pyuno object (com.sun.star.uno.XInterface)0x47c0dac{, supportedInterfaces={com.sun.star.uno.XComponentContext,com.sun.star.container.XNameContainer,com.sun.star.lang.XTypeProvider,com.sun.star.uno.XWeak,com.sun.star.lang.XComponent}} >>> Reproducible: Always User Profile Reset: No Additional Info: Versions 5.4 & 6.x typically display msgbox(es) User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
I tried running the LibO Python on Win, but it complained about a missing python35.dll. I don't know how to import the officehelper using system Python. I tried on Linux. Adding Xisco as he is Mr Python.
I could confirm the bug. I don't know how it could work before, but the bug is the first given parameter to spawnv which is not quoted (and the path has spaces in windows). If you change the line cmdArray = (sOffice, "--nologo", "--nodefault", "".join(["--accept=pipe,name=", sPipeName, ";urp;"])) to cmdArray = ('"{}"'.format(sOffice), "--nologo", "--nodefault", "".join(["--accept=pipe,name=", sPipeName, ";urp;"])) it works fine. I don't know how its with linux. When it's there a problem, you could add a sOfficeQuoted variabel and decide in the "if" above (for the extension) to quote or not the "sOffice" variable! @Buovjaga You should use the python.exe in the folder "C:\Program Files (x86)\LibreOffice 5\program"! Not the one in the subfolder bin (this is called by the oher python.exe with needed environment variables)
(In reply to mini-matze from comment #2) > @Buovjaga > You should use the python.exe in the folder "C:\Program Files > (x86)\LibreOffice 5\program"! Not the one in the subfolder bin (this is > called by the oher python.exe with needed environment variables) Yes, it seems this is my Achilles' heel - recently I asked about it on IRC and was told to use the python.exe wrapper.
I think a more better solution were to use subprocess instead of the "old" os.spawn. So we need not care about quoting (and to set it as first arg, too). add to imports: from subprocess import Popen Then we need to replace the process creation: replace: os.spawnv(os.P_NOWAIT, sOffice, cmdArray) with: Popen( cmdArray ) Or alternativ (because the first arg is the path to use - it's cleaner): replace: cmdArray = (sOffice, "--nologo", "--nodefault", "".join(["--accept=pipe,name=", sPipeName, ";urp;"])) os.spawnv(os.P_NOWAIT, sOffice, cmdArray) with: cmdArray = ("--nologo", "--nodefault", "".join(["--accept=pipe,name=", sPipeName, ";urp;"])) Popen( (sOffice,) + cmdArray ) Hope this helps...
If I'm not wrong, subprocess.Popen objects are designed as context managers that handle resource allocation and releasing, which os.spawn may miss. Can I invite you to check for https://gitlab.com/LibreOfficiant/ide_utils project? It's been built on top of officehelper in order to ease Python macros development for LibreOffice and OpenOffice within IDE's such as Geany and PyCharm. It may extend officehelper features and promote Python macros development within LibreOffice. Notice its @retry decorator that leverages connection attempts.
First of all let me say you're free to modify officehelper.py any time you want. However let me point out that "that very same code" is functioning fine in OpenOffice and in LibreOffice up to version 5.3.7 excluded. At first sight, something has been modified in LibreOffice itself or within Python 3 itself from release 5.3.7. I tend to think that solely modifying officehelper.py code, for good, may leave the root cause of the module's misbehaviour unidentified. Cordially
(In reply to Alain H Romedenne from comment #6) > First of all let me say you're free to modify officehelper.py any time you > want. > > However let me point out that "that very same code" is functioning fine in: > o OpenOffice > o LibreOffice 64 bits up to version 5.3.7 excluded > o LibreOffice 32 bits all PortableApps versions > At first sight, something has been modified in LibreOffice itself or within > Python 3 itself from release 5.3.7. > > I tend to think that solely modifying officehelper.py code, for good, may > leave the root cause of the module's misbehaviour unidentified. > > Cordially
Dear Alain H Romedenne, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from http://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
retested successfully under Windows Version: 6.2.4.2 (x64) Build ID: 2412653d852ce75f65fbfa83fb7e7b669a126d64 CPU threads: 12; OS: Windows 10.0; UI render: GL; VCL: win; Locale: en-IE (en_IE); UI-Language: en-GB Calc: threaded
retested unsuccessfully under Linux Version: 6.2.4.2 Build ID: 1:6.2.4-0ubuntu0.19.04.1 Threads CPU: 1; Os : Linux 5.0; UI Render : par défaut; VLC: gtk3; Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR Calc: threaded
(In reply to LibreOfficiant from comment #10) > retested unsuccessfully under Linux > > Version: 6.2.4.2 > Build ID: 1:6.2.4-0ubuntu0.19.04.1 > Threads CPU: 1; Os : Linux 5.0; UI Render : par défaut; VLC: gtk3; > Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR > Calc: threaded Then we should put back to NEW.
retested unsuccessfully under Linux with APPIMage file Version: 6.2.4.2 Build ID: 241265....126d64 Threads CPU: 1; OS : Linux 5.0; UI Render : par défaut; VLC: gtk3; Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR Calc: threaded
Dear LibreOfficiant, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
Alain Romedenne committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/d8978a8c4ffabd6b36a691fd3e2df68563808234 tdf#116156 tdf#157162 tdf#159528 Fix glitches in officehelper.py It will be available in 24.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.