noembryo / KoHighlights

KOHighlights is a utility for viewing KOReader's highlights and/or export them to simple text, html, csv or markdown files.
MIT License
128 stars 5 forks source link

file explorer not opening in Linux - Manjaro GNOME #8

Closed richo67 closed 3 years ago

richo67 commented 4 years ago

Hi, It is failing to open folder with lua file on Linux. In Windows it works fine. After selecting menu Open location following is dumped in terminal stderr and no file browser is opened.

xdg-mime: no method available for querying MIME type of '/home/richo/CloudStation/aKnihy/_books/Atomic Habits - James Clear.sdr'
xdg-mime: mimetype argument missing
Try 'xdg-mime --help' for more information.
/usr/bin/xdg-open: line 881: x-www-browser: command not found
/usr/lib/firefox/firefox: /tmp/_MEIlYRQpG/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/lib/firefox/firefox)
/usr/bin/xdg-open: line 881: iceweasel: command not found
/usr/bin/xdg-open: line 881: seamonkey: command not found
/usr/bin/xdg-open: line 881: mozilla: command not found
/usr/bin/xdg-open: line 881: epiphany: command not found
/usr/bin/xdg-open: line 881: konqueror: command not found
/usr/bin/xdg-open: line 881: chromium: command not found
/usr/bin/xdg-open: line 881: chromium-browser: command not found
/usr/bin/xdg-open: line 881: google-chrome: command not found
/usr/bin/xdg-open: line 881: www-browser: command not found
/usr/bin/xdg-open: line 881: links2: command not found
/usr/bin/xdg-open: line 881: elinks: command not found
/usr/bin/xdg-open: line 881: links: command not found
/usr/bin/xdg-open: line 881: lynx: command not found
/usr/bin/xdg-open: line 881: w3m: command not found
xdg-open: no method available for opening '/home/richo/CloudStation/aKnihy/_books/Atomic Habits - James Clear.sdr'

Looking at your code it should use *xdg-open folder_path" which works from my command line even I made little copy of your code (as follows) and it is working from it.

import os, sys, re
import subprocess

path="//home"

try:
    if sys.platform == "win32":
        os.startfile(path)
    else:
        opener = "open" if sys.platform == "darwin" else "xdg-open"
        subprocess.call([opener, path])
except OSError:
    self.popup(_("Error opening target!"),
               _('"{}" does not exists!').format(path))

It is something which is hidden in the executable build which is ignoring some environment variables available in my normal environment?

noembryo commented 4 years ago

I'm really ignorant when it comes to linux command line... :o( The opener line came from someone's suggestion..

I just check it in a XUbuntu VM I use, and its working fine.. Linux2 I think the problem is that at your system the xdg-open is interpreted as a url and a web browser is called... It must be because of the xdg-mime: mimetype argument missing but I have no idea what is expected there. I also can't test anything, since its working in my VM..

Any ideas?

noembryo commented 4 years ago

Maybe there is a solution here?

richo67 commented 4 years ago

Somehow it must be related to how you made the executable (or what it is) for linux, because as I wrote when I run mine piece of code using python3 it works. So it may have something with environment in which the executable bundle runs. I assume you build it in your XUbuntu VM and that is why it has that settings.

P.S.: I can not run the source which I clone from github because I have python 3.8 and PySide is supporting only up to 3.5 and I am not able to run it with python2 because mym pip is using python3.

noembryo commented 4 years ago

It turns out that the code I use, is recommencement here and here as a standard multi-platform approach. I couldn't find anything better..

As for the github code, it's almost ready to run using Pyside2 too. If you like, I can send you a zip that is Python3/PySide2 compatible, to experiment..

Edit: Send it to your mail...

richo67 commented 4 years ago

Thanks for the code, could you also share with me how do you build that executable for a Linux. I may try to reproduce it here and see if it will work if I build it here. I will test code from email to run it using python direclty to see if it will work.

noembryo commented 4 years ago
sudo pip install pyinstaller
pyinstaller --onefile --name KoHighlights main.py
noembryo commented 4 years ago

I think that the mimeapps.list idea is worth pursuing..

richo67 commented 4 years ago

The code you sent me is working much better on my system than the build. It only has black font on dark background (QT settings?) By nice I mean it doesn't give any errors or anything while the executable give milions errors for fonts and some other QT errors (I think this is because is build on certain Linux which is different from mine.) Anyway I can open folder nicely now from source. Going to build one using pyinstaller to see...

richo67 commented 4 years ago

I think that the mimeapps.list idea is worth pursuing..

In my env it is OK and working. I still think it has to do something with that onefile pyinstaller created in different environment.

richo67 commented 4 years ago

I made the single file (181MB !) and it is working fine, except the black font on black

Screenshot from 2020-05-18 14-42-44

richo67 commented 4 years ago

I used qt5ct and set light theme now all is fine!

noembryo commented 4 years ago

I made the single file (181MB !) and it is working fine, except the black font on black

Aouch!! Well, since you can run the main.py script, there is no reason to compile it too..

What distribution do you use? How come is not compatible with Ubuntu? I thought that the Ubuntu flavor was the most mainstream of them all..

richo67 commented 4 years ago

I think it very much depends on which distribution you make that one file. Maybe you can try to run mine on your xubutnu. I use Manjaro it is a flaour of Arch. And yes you are right that ubuntu is one of most common but there are many many more very popular arch/manjaro is one of them and then you have debian amd fedora, suse. Those are the most common, but arch, ubuntu, fedora are all different.

It is also possible that inside of mine onefile are all fonts an libraries. when I run your onefile I got all notifications about missing stuff. It works but it probably goes default to something. I will send you link in email to download onefile from me, I would be curious how it works on your ubuntu.

noembryo commented 4 years ago

It is also possible that inside of mine onefile are all fonts an libraries. when I run your onefile I got all notifications about missing stuff. It works but it probably goes default to something.

The defaults were used anyways for the app (for fonts that is)

I will send you link in email to download onefile from me, I would be curious how it works on your ubuntu.

OK, but I don't thing that it will work, because I'm guessing you got a newer linux version than me. I use an older (16.04) distribution of XUbuntu for compatibilty with more versions. As I heard, apps that were build with a distribution will work on the newer versions but not in older...

richo67 commented 4 years ago

Well ubuntu and manjaro are not compatible, but python is so let us see :-)

noembryo commented 4 years ago

Well, it will take some time to get here ;o) BTW the link was not compatible with Chrome (Vivaldi actually) but it works with Firefox.

richo67 commented 4 years ago

Let me know once it arrives and you run it. I was also wondering if there would not be easier to deliver for Linux just python files in form of zip or something. Anybody would just need to have python3 install and install all the needed dependencies, maybe it could be automatize in some way.

noembryo commented 4 years ago

It arrived, but as I was expecting, it does not run.

[8135] Error loading Python lib '/tmp/_MEIvqtASp/libpython3.8.so.1.0': dlopen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/_MEIvqtASp/libpython3.8.so.1.0)

it can not find its own bundled python...

I was also wondering if there would not be easier to deliver for Linux just python files in form of zip or something. Anybody would just need to have python3 install and install all the needed dependencies, maybe it could be automatize in some way.

But the source (the python files) exist with every release as zip or tar.gz archives. All distributions have Python 2.x. I guess, I could also add a zip with the Pyside2 version. Pyside does work with some Python 3.x but for the latest versions..

noembryo commented 4 years ago

Added PySide2 version...