Added complex fules to determine whether soffice is LibreOffice, for the vender-installed LibreOffice on Linux.

This commit is contained in:
依瑪貓 2016-12-24 06:42:44 +08:00
parent 42ab15c6d0
commit cd92b7838d

View File

@ -362,7 +362,7 @@ class Office:
self.port self.port
# LibreOffice on POSIX systems uses --accept instead of # LibreOffice on POSIX systems uses --accept instead of
# -accept now. # -accept now.
if ooexec.lower().find("libreoffice") != -1: if self.is_ooexec_lo(ooexec):
param = "-" + param param = "-" + param
try: try:
os.execl(ooexec, ooexec, param) os.execl(ooexec, ooexec, param)
@ -399,5 +399,21 @@ class Office:
# Not found # Not found
return None return None
def is_ooexec_lo(self, ooexec):
""" Checks whether the soffice executable is LibreOffice.
LibreOffice on POSIX systems uses --accept instead of
-accept now. """
# This works for most cases.
if ooexec.lower().find("libreoffice") != -1:
return True
# Checks the symbolic link at /usr/bin/soffice
if ooexec == "/usr/bin/soffice" and os.path.islink(ooexec):
if os.readlink(ooexec).lower().find("libreoffice") != -1:
return True
# Not found
return False
if __name__ == "__main__": if __name__ == "__main__":
main() main()