From 89b1e4a21e80d53be0e28df8723eec36358034f9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 19 Oct 2023 13:32:28 +0200 Subject: ✨ imports: manage ods, xls and xlsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert them to CSV and store the resulting file in a specific field. --- ishtar_common/libreoffice.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ishtar_common/libreoffice.py') 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 = () -- cgit v1.2.3