diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-10-19 13:32:28 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-05 10:51:52 +0100 |
commit | 0e87aae64761766e8f74328a8e68e079062aa0af (patch) | |
tree | 8a77c4f2afa4fcab3d24604633e8fe5a55a7d56d /ishtar_common/libreoffice.py | |
parent | e6dab88f74f0f13ab047b4f0059c7f1e469118f3 (diff) | |
download | Ishtar-0e87aae64761766e8f74328a8e68e079062aa0af.tar.bz2 Ishtar-0e87aae64761766e8f74328a8e68e079062aa0af.zip |
✨ imports: manage ods, xls and xlsx
Convert them to CSV and store the resulting file in a specific field.
Diffstat (limited to 'ishtar_common/libreoffice.py')
-rw-r--r-- | ishtar_common/libreoffice.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ishtar_common/libreoffice.py b/ishtar_common/libreoffice.py index 7dbb36e30..3869ca81a 100644 --- a/ishtar_common/libreoffice.py +++ b/ishtar_common/libreoffice.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - import time import uno @@ -9,14 +8,14 @@ from com.sun.star.beans import PropertyValue from com.sun.star.connection import NoConnectException from com.sun.star.sheet.ValidationType import LIST -from com.sun.star.table import CellRangeAddress, CellAddress +#from com.sun.star.table import CellRangeAddress, CellAddress from ishtar_common.utils import num2col from django.conf import settings -RETRY = 1 +RETRY = 5 class UnoClient: @@ -45,7 +44,7 @@ class UnoClient: if self.remote_context and self.desktop: return try_nb = 0 - while not self.service_manager or try_nb > RETRY: + while not self.service_manager and try_nb <= RETRY: self.connect() try_nb += 1 if not self.service_manager: @@ -64,6 +63,8 @@ class UnoClient: def get_document(self, filename, propval=None): self.create_context() + if not self.remote_context or not self.desktop: + return url = "file://{}".format(filename) if not propval: propval = () |