Nyre221 / dolphin-quick-view

GNU General Public License v3.0
79 stars 5 forks source link

failed xls /xlsx / ods preview #12

Closed guiodic closed 1 year ago

guiodic commented 1 year ago

` /home/guido/.config/quick_view/dolphin_quick_view_shortcut.sh Pasolini\ Hostia\ elenco\ opere\ assicurazione\ con\ ritorni.xlsx method return time=1695136919.170724 sender=:1.19 -> destination=:1.815 serial=6095 reply_serial=2 method return time=1695136919.188539 sender=:1.190 -> destination=:1.818 serial=698 reply_serial=2 method return time=1695136919.302900 sender=:1.19 -> destination=:1.820 serial=6097 reply_serial=2 Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/guido/.config/quick_view/quick_view.pyz/main.py", line 4, in File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 307, in launch File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 59, in init File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 150, in load_file_at_index File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 191, in load_table_viewer File "/home/guido/.config/quick_view/quick_view.pyz/table_viewer.py", line 11, in load_file File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel/core.py", line 37, in get_sheet File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel/internal/core.py", line 21, in get_sheet_stream File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel/plugins/sources/file_input.py", line 38, in get_data File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel/plugins/parsers/excel.py", line 19, in parse_file File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel/plugins/parsers/excel.py", line 40, in _parse_any File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_io/io.py", line 86, in get_data

version however.

              ^^^^

File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_io/io.py", line 105, in _get_data for klass in (StringIO, TextIOWrapper): ^^^^^^^^^^^^^^^^^^^^^ File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_io/io.py", line 191, in load_data File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_io/reader.py", line 47, in open File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_xls/xlsr.py", line 179, in init File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_xls/xlsr.py", line 146, in init File "/home/guido/.config/quick_view/quick_view.pyz/pyexcel_xls/xlsr.py", line 165, in get_xls_book File "/home/guido/.config/quick_view/quick_view.pyz/xlrd/init.py", line 130, in open_workbook File "/home/guido/.config/quick_view/quick_view.pyz/xlrd/xlsx.py", line 812, in open_workbook_2007_xml File "/home/guido/.config/quick_view/quick_view.pyz/xlrd/xlsx.py", line 266, in process_stream AttributeError: 'ElementTree' object has no attribute 'getiterator' `

guiodic commented 1 year ago

not sure this is the correct path because it fails also for pdf, anyway PDF works with quick_view il dolplin while xls /xlsx /ods fail

guiodic commented 1 year ago

also ~/.config/quick_view/quick_view.pyz fails:

~/.config/quick_view/quick_view.pyz modulo_portabilità.pdf Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/guido/.config/quick_view/quick_view.pyz/main.py", line 4, in File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 307, in launch File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 42, in init ValueError: 'modulo_portabilità.pdf' is not in list

~/.config/quick_view/quick_view.pyz elenco\ opere\ Caravaggio\ Basilea\ -\ Korea\ 2.xlsx Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/guido/.config/quick_view/quick_view.pyz/main.py", line 4, in File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 307, in launch File "/home/guido/.config/quick_view/quick_view.pyz/quick_view.py", line 42, in init ValueError: 'elenco opere Caravaggio Basilea - Korea 2.xlsx' is not in list

Dolphin shows nothin in terminal so I'm not able to debug...

Nyre221 commented 1 year ago

Hi, thanks for the report.

~/.config/quick_view/quick_view.pyz modulo_portabilità.pdf

"modulo_portabilità.pdf" is not a path.

you can do it this way if your working directory is the folder where the file is: ~/.config/quick_view/quick_view.pyz ./modulo_portabilità.pdf

If the file is in the user's home folder: ~/.config/quick_view/quick_view.pyz ~/modulo_portabilità.pdf or ~/.config/quick_view/quick_view.pyz /home/USERNAME/modulo_portabilità.pdf

The simplest thing is to write ~/.config/quick_view/quick_view.pyz and drag the file into the terminal. konsole will insert the complete path for you.

I wasn't aware that it could fail like this without giving a clear message, I'll fix it in the future.

'ElementTree' object has no attribute 'getiterator'

I recently noticed this problem too and I don't know if it can be easily fixed. All I know now is that the problem occurs when using the application packaged via zipapp (.pyz)

maybe what I can do is exclude pyexcel from the .pyz package and see if that works, but this, even if it works, would then require users to install pyexcel via pip.

I'll find a solution when I have more time.

For now you can do two things: 1: Try the second version (pyexcel is not included in the .pyz): https://github.com/Nyre221/dolphin-quick-view/releases/tag/v1.1 2: download the project from github and launch quick view from its folder. obviously this requires you to modify the shortcut code.

Thanks again.

Nyre221 commented 1 year ago

@guiodic

The problem with the ods was due to the absence of a dependency, the one with the xlsx files was due to a problem with the .pyz package

~/.config/quick_view/quick_view.pyz modulo_portabilità.pdf

Now quick view can open relative paths like the one you wrote.

soon I will release a beta version where everything should work.

Nyre221 commented 1 year ago

@guiodic

https://github.com/Nyre221/dolphin-quick-view/releases/tag/v1.2.3_RC1

At the moment there is still an issue where xlsx,csv,ods files may not always load. This is fixable and I will make another release in the next few days.

guiodic commented 1 year ago

it works, anyway it's limited (no color, no images, ecc.), not ideal.

Nyre221 commented 1 year ago

@guiodic

it's to get a quick idea of the document and it can't be heavy. Furthermore, displaying xlsx,ods,etc is no small task.

guiodic commented 1 year ago

I understand, but I stand by the idea I wrote to you in another post. The best thing is to convert the file to PDF with libreoffice/unoconv and display it.

Nyre221 commented 1 year ago

@guiodic I can try to do it this way: if the file is under 1/1.5mb it shows the preview, otherwise it shows an error message. This way I can also display the odt/doc,etc in a decent way and completely eliminate the use of texextract and pyexcel.

tell me a few things: 1: what size is your average xlsx, doc, etc file in MB? 2: if you use libreoffice --headless --convert-to pdf /path/to/file.ods/xlsx/etc is the pdf generated correctly? are there any graphic errors, etc? 3: how long does it take to convert files to pdf in your case?

guiodic commented 1 year ago

25 mb xlsx 4.12 secs

10 mb xlsx 2.14

2 mb xlsx 1.16 secs

IMHO 3-4 seconds are tolerable (it's less than open the document with libreoffice) provided that the Quick View window opens immediately and shows a waiting animation in the meantime.

Docx are very faster, 1-2 seconds for more than 50 mb docx with a lot of images.

Intel i5 11th gen, mobile.

The quality of conversion is the same of opening them in libreoffice

Nyre221 commented 1 year ago

@guiodic

Docx are very faster, 1-2 seconds for more than 50 mb docx with a lot of

Can you go here and download the 2mb one? (it's a .doc): https://sample-videos.com/download-sample-doc-file.php

In my case it takes 15 seconds...

maybe it's a problem only with .doc files

edit: I wonder if it depends on the number of pages and not on the size.

guiodic commented 1 year ago

I tried to convert it in docx and it's even worse....

guiodic commented 1 year ago

well, it has about 900 pages... i presume this is the problem

Nyre221 commented 1 year ago

@guiodic

well, it has about 900 pages... i presume this is the problem

Probably.

I can put a time limit (6 seconds) that stops the process if it takes too long.

guiodic commented 1 year ago

anyway, a 112 .doc pages only 1.12 secs (only text, no images)

Nyre221 commented 1 year ago

@guiodic

anyway, a 112 .doc pages only 1.12 secs (only text, no images)

Good to know, thanks!

I'll let you know when the new version is available.

Nyre221 commented 1 year ago

@guiodic here: https://github.com/Nyre221/dolphin-quick-view/releases/tag/v1.2.3_RC2

If you have libreoffice installed with the package manager make sure you have the libreoffice-calc, libreoffice-impress and libreoffice-writer packages.

you can also use the flatpak version but it needs to be configured: sudo flatpak override org.libreoffice.LibreOffice --filesystem=/tmp

guiodic commented 1 year ago

It works!

Nyre221 commented 1 year ago

@guiodic

Great! Let me know if there is any problem.

guiodic commented 1 year ago

Thank you very much!

Nyre221 commented 1 year ago

@guiodic

I fixed an issue that caused the preview to not load: https://github.com/Nyre221/dolphin-quick-view/releases/tag/v1.2.3_RC3