summaryrefslogtreecommitdiff
path: root/ishtar_common/libreoffice.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-10-19 13:32:28 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-04-16 16:38:32 +0200
commit89b1e4a21e80d53be0e28df8723eec36358034f9 (patch)
tree979c247c80b26c93da7e029657fae3501cbf5f9b /ishtar_common/libreoffice.py
parentd71382379f5c806a5b5c8cafd06d7e60564b8d4a (diff)
downloadIshtar-89b1e4a21e80d53be0e28df8723eec36358034f9.tar.bz2
Ishtar-89b1e4a21e80d53be0e28df8723eec36358034f9.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.py9
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 = ()