-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python-UNO bridge to libreoffice inside docker container. #108
Conversation
Add a Python-UNO bridge to libreoffice running inside a docker container.
Thanks a lot. Is docker/lo-ubuntu2204/poetry.lock part of the PR for a reason or by accident? Seems like we are using the hard coded port 2022, but it is probably unlikely that this used. |
Avoid hard coding the port numbers. Added dynamic port handling through environment variables.
@blattms Yes. Good comment, we should get rid of the hard coded port numbers. I have updated this PR to include dynamic port handling through environment variables. |
@blattms I followed the practice described here: https://python-poetry.org/docs/basic-usage/. Quote: |
thanks a lot. I would merge this as is. @lisajulia if you would you take a short look at the python code, that would be really cool. Feel free to merge after that. |
update_indexes(doc) | ||
|
||
# Save the document | ||
#doc.store() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended to be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is intended. The user can save the document from the menu for now. If we want to automate the saving process we can do that by running libreoffice in headless mode using doc.store() as you mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment in the source code also, see latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I find instruction on how to use our docker stuff. I did use it on another machine.
Did execute build-image.sh but with either start-container.sh or /docker-soffice.sh I get:
See 'docker run --help'.
I must be missing something.
docker/lo-ubuntu2204/README.md
Outdated
``` | ||
$ python -m venv .venv | ||
$ source .venv/bin/activate | ||
$ pip install . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For dummies like me we should probably mention that one has to be in subdirectory docker/lo-ubuntu2204 for this to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes thanks for the reminder! I have updated the README.md with this information
@blattms I will test this on a Windows and Mac machine to see if there are any issues. |
Added instructions for how to run libreoffice in docker container on Windows.
@blattms I tested the |
@blattms It is in the README.md file. I have updated it with more information, see latest commit. Let me known if something is still missing |
67c2f36
to
7fd1b2e
Compare
After fixing the above, I see "this file has been locked by another user" |
The above sentence was wrong. It is the dialog about links to external data that I am still seeing. |
Should the indices be updated automatically, now? On my system they are not updated. |
Added a trailing slash to the destination directory of the COPY command. It was reported that this slash was necessary for some version of docker.
@blattms Interesting. This dialog should be gone now due to the modification of the config file done by the call to
|
@blattms Sorry, I thought you were running the |
Added information about the difference between the docker-soffice.sh and start-container.sh scripts.
@blattms If you are running |
thanks. After I learned how to reinstall e.g. open_file.py, the dialog is indeed gone when using start-container.py. Indices are update automatically, which is very cool. There is a small caveaT. For the very last entries (A.10 SAVE FILES), the page numbers are not correct. Probably a race condition between rendering (which is not 100% finished) and updating the index. I guess this is tiny and we can live with that. I still see a dialog about the locked libreoffice file, though. Do you see that, too? Maybe this is remnant of a killed liberoffice on my system? Or is it intended to prevent users from saving? |
@blattms Yes, I think I have seen those files, they look like this: |
@blattms Do you get correct page numbers when you open |
It seems sufficient to test using docker-soffice.shh and updating the index manual (I have todo save-as before as the file is readonly). Yes doing manually the page number displayed is the one in the footer if we jump to that page. |
The problem is not only the dialog. You also cannot change the document (e.g. update the index). Is there a way to remove the lock file inside docker? |
@blattms Not sure. Since those files are actually on the host not inside the container, see line 73 in
where we mount the host directory into the container. I think those files needs to be removed on the host manually (or by a script) before we open a file. The problem with using a script is that the script should not remove a lock file if libreoffice is actually open with that file. So the script needs to determine if libreoffice is using the lock file or not. |
@blattms It should not be a race condition since the
The index is then updated at line 52 after the document has been loaded. I will do some more tests on this. |
Add an extra command to the docker server's rest API that allows to load a document without updating the index.
Added new commit to allow the docker server to only load the files (without updating the index at the same time). Using this newly added function to only load the document and then manually updating the index afterwards, seems to give correct page number in the index. So it seems there is something going on (a bug?) with the PyUNO call
|
Thanks a lot for the additions and the infos. |
Added a Python-UNO bridge to LibreOffice running inside a docker container. This can be used to automatically
update indices. And also hopefully do other things that we want to automate in the future, like saving the PDF file.