Added complex rules to find the soffice executable, to deal with LibreOffice on MacOSX, and Linux OpenOffice/LibreOffice vender installation.
This commit is contained in:
parent
0ad8fcbacf
commit
28c877c6fa
1
TODO
1
TODO
@ -5,4 +5,3 @@ obasync TODO
|
|||||||
* Linux system-bundled LibreOffice.
|
* Linux system-bundled LibreOffice.
|
||||||
* Writes the README (reStructureText).
|
* Writes the README (reStructureText).
|
||||||
* Documentation.
|
* Documentation.
|
||||||
* Python 3
|
|
||||||
|
35
bin/obasync
35
bin/obasync
@ -352,8 +352,12 @@ class Office:
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return
|
return
|
||||||
os.setsid()
|
os.setsid()
|
||||||
ooexec = os.path.join(
|
ooexec = self.find_posix_ooexec()
|
||||||
os.path.dirname(uno.__file__), "soffice")
|
if ooexec is None:
|
||||||
|
print("Failed to find the "
|
||||||
|
"OpenOffice/LibreOffice installation.",
|
||||||
|
file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
os.execl(ooexec, ooexec,
|
os.execl(ooexec, ooexec,
|
||||||
"-accept=socket,host=localhost,port=%d;urp;" %
|
"-accept=socket,host=localhost,port=%d;urp;" %
|
||||||
@ -364,5 +368,32 @@ class Office:
|
|||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def find_posix_ooexec(self):
|
||||||
|
""" Finds the OpenOffice/LibreOffice executable on POSIX
|
||||||
|
systems (Linux or MacOSX). """
|
||||||
|
# Checkes soffice in the same directory of uno.py
|
||||||
|
# This works for Linux OpenOffice/LibreOffice local
|
||||||
|
# installation, and OpenOffice on MacOSX.
|
||||||
|
ooexec = os.path.join(
|
||||||
|
os.path.dirname(uno.__file__), "soffice")
|
||||||
|
if os.path.exists(ooexec):
|
||||||
|
return ooexec
|
||||||
|
|
||||||
|
# Now we have LibreOffice on MacOSX and Linux
|
||||||
|
# OpenOffice/LibreOffice vender installation.
|
||||||
|
|
||||||
|
# LibreOffice on MacOSX.
|
||||||
|
ooexec = "/Applications/LibreOffice.app/Contents/MacOS/soffice"
|
||||||
|
if os.path.exists(ooexec):
|
||||||
|
return ooexec
|
||||||
|
|
||||||
|
# Linux OpenOffice/LibreOffice vender installation.
|
||||||
|
ooexec = "/usr/bin/soffice"
|
||||||
|
if os.path.exists(ooexec):
|
||||||
|
return ooexec
|
||||||
|
|
||||||
|
# Not found
|
||||||
|
return None
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user