Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux, obok: undefined variable causes crash #156

Closed
dcbaker opened this issue Nov 28, 2016 · 7 comments
Closed

Linux, obok: undefined variable causes crash #156

dcbaker opened this issue Nov 28, 2016 · 7 comments

Comments

@dcbaker
Copy link

dcbaker commented Nov 28, 2016

Traceback (most recent call last):
  File "calibre_plugins.obok_dedrm.action", line 96, in launchObok
  File "calibre_plugins.obok_dedrm.obok.obok", line 351, in __init__
NameError: global name 'linux_path' is not defined

the linux_path variable isn't defined anywhere as far as I can see, even searching for it. I assume that it needs to point to the wine prefix to find the kobo database?

@apprenticeharper
Copy link
Owner

That looks like a good guess. I'm not sure that obok has been properly tested under Linux.

@norbusan
Copy link
Contributor

I am running obok on linux quite regularly, without problems, but this is version maybe 3.1.8:

PLUGIN_NAME = 'Obok DeDRM'
PLUGIN_SAFE_NAME = PLUGIN_NAME.strip().lower().replace(' ', '_')
PLUGIN_DESCRIPTION = _('Removes DRM from Kobo kepubs and adds them to the library.')
PLUGIN_VERSION_TUPLE = (3, 1, 8)

And there is nowhere a linux_path to be found. Seems that later changes have broken the plugin.

@norbusan
Copy link
Contributor

Ok, this and issue 162 are the same, and have been introduced in git commit 3e95168:

@@ -338,6 +341,9 @@ class KoboLibrary(object):
                 self.kobodir = os.path.join(self.kobodir, u"Kobo", u"Kobo Desktop Edition")
             elif sys.platform.startswith('darwin'):
                 self.kobodir = os.path.join(os.environ['HOME'], u"Library", u"Application Support", u"Kobo", u"Kobo Desktop Edition")
+            elif linux_path != None:
+                # Probably Linux, let's get the wine prefix and path to Kobo.
+                self.kobodir = os.path.join(linux_path, u"Local Settings", u"Application Data", u"Kobo", u"Kobo Desktop Edition")
             # desktop versions use Kobo.sqlite
             kobodb = os.path.join(self.kobodir, u"Kobo.sqlite")
             # check for existence of file

Not sure what this change should do, but removeing the elif linux_path clause should fix the problem.

@apprenticeharper
Copy link
Owner

It seems to be an attempt to locate the Kobo Desktop database directory when running under Linux/Wine. I clearly introduced this when merging in fixes from a couple of versions. I'm trying to find where I got this bit from and see how best to fix it. I'm guessing that linux_path is meant to be set to the Wine prefix.

@apprenticeharper
Copy link
Owner

I've checked in a version with those two lines commented out. If anyone has code that actually allows the plugin to work with Kobo Desktop under Wine, I'd be very pleased to include it.

@das-delta
Copy link

I had the same issue as dcbaker.

Maybe it helps; here's how I got the plugin to work today:
I'm using Calibre 2.76 under Linux, the newest version of the obok plugin from https://github.com/apprenticeharper/DeDRM_tools/blob/master/Obok_calibre_plugin/obok_plugin.zip, and Kobo Desktop Edition 4.2.6122 (installed with winetricks) in wine.

I modified obok/obok.py: the linux_path error happens in KoboLibrary's __init__.
Important detail: with my setup, the Kobo sqlite database does not reside in the wine directory, but in my home directory. So I ignored the linux_path and simply hardcoded the self.kobodir for my particular setup

elif sys.platform.startswith('linux'):
   self.kobodir = os.environ['HOME']

It would probably be good to have that path in a config file later on.

Then I restarted calibre
calibre-debug -s; calibre-customize -b /home/delta/Downloads/z/; calibre-debug -g
and was able to select books to import.

I then got another error (no userkeys found) from the __getmacaddrs method because my wine installation has no ipconfig executable installed.

The if-clause for Darwin can be used for Linux as well:

   elif sys.platform.startswith('darwin') or sys.platform.startswith("linux"):

Hope that helps!

@apprenticeharper
Copy link
Owner

Fixed included in the DeDRM 6.5.3 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants