Added complex fules to determine whether soffice is LibreOffice, for the vender-installed LibreOffice on Linux.
This commit is contained in:
		
							
								
								
									
										18
									
								
								bin/obasync
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								bin/obasync
									
									
									
									
									
								
							| @@ -362,7 +362,7 @@ class Office: | ||||
|             self.port | ||||
|         # LibreOffice on POSIX systems uses --accept instead of | ||||
|         # -accept now. | ||||
|         if ooexec.lower().find("libreoffice") != -1: | ||||
|         if self.is_ooexec_lo(ooexec): | ||||
|             param = "-" + param | ||||
|         try: | ||||
|             os.execl(ooexec, ooexec, param) | ||||
| @@ -399,5 +399,21 @@ class Office: | ||||
|         # Not found | ||||
|         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__": | ||||
|     main() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user