summaryrefslogtreecommitdiffstats
path: root/Obok_calibre_plugin
diff options
context:
space:
mode:
authorNorbert Preining <[email protected]>2015-09-18 09:10:06 +0900
committerNorbert Preining <[email protected]>2015-09-18 09:10:06 +0900
commitfe6074949bda4e2d50ca69db4424a27b53b477be (patch)
treedb4efd3a4dbeaa39685ad7acea8665d60bb2e776 /Obok_calibre_plugin
parent2db7ee8894a2145c6b9f29d994c63e139a83f532 (diff)
obok.py: first try device, and only if that fails fall back to Desktop progs
Diffstat (limited to 'Obok_calibre_plugin')
-rw-r--r--Obok_calibre_plugin/obok_plugin/obok/obok.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/Obok_calibre_plugin/obok_plugin/obok/obok.py b/Obok_calibre_plugin/obok_plugin/obok/obok.py
index f845185..ca74284 100644
--- a/Obok_calibre_plugin/obok_plugin/obok/obok.py
+++ b/Obok_calibre_plugin/obok_plugin/obok/obok.py
@@ -248,29 +248,31 @@ class KoboLibrary(object):
print u"Obok v{0}\nCopyright © 2012-2015 Physisticated et al.".format(__version__)
self.kobodir = ''
kobodb = ''
- if sys.platform.startswith('win'):
- if sys.getwindowsversion().major > 5:
- self.kobodir = os.environ['LOCALAPPDATA']
- else:
- self.kobodir = os.path.join(os.environ['USERPROFILE'], 'Local Settings', 'Application Data')
- self.kobodir = os.path.join(self.kobodir, 'Kobo', 'Kobo Desktop Edition')
- elif sys.platform.startswith('darwin'):
- self.kobodir = os.path.join(os.environ['HOME'], 'Library', 'Application Support', 'Kobo', 'Kobo Desktop Edition')
- # desktop versions use Kobo.sqlite
- kobodb = os.path.join(self.kobodir, 'Kobo.sqlite')
- if (self.kobodir == '' or not(os.path.exists(kobodb))):
- # kobodb is either not set or not an existing file, that means that either:
- # . windows or mac: desktop app is not installed
- # . linux
- # we check for a connected device and try to set up kobodir and kobodb from there
- if (device_path):
- self.kobodir = os.path.join(device_path, '.kobo')
- # devices use KoboReader.sqlite
- kobodb = os.path.join(self.kobodir, 'KoboReader.sqlite')
- if (not(os.path.exists(kobodb))):
- # give up here, we haven't found anything useful
- self.kobodir = ''
- kobodb = ''
+
+ # - first check whether serials have been found or are provided
+ # and a device is connected. In this case, use the device
+ # - otherwise fall back to Kobo Desktop Application for Windows and Mac
+ if (device_path and (len(serials) > 0)):
+ self.kobodir = os.path.join(device_path, '.kobo')
+ # devices use KoboReader.sqlite
+ kobodb = os.path.join(self.kobodir, 'KoboReader.sqlite')
+ if (not(os.path.exists(kobodb))):
+ # give up here, we haven't found anything useful
+ self.kobodir = ''
+ kobodb = ''
+
+ if (self.kobodir == ''):
+ # we haven't found a device with serials, so try desktop apps
+ if sys.platform.startswith('win'):
+ if sys.getwindowsversion().major > 5:
+ self.kobodir = os.environ['LOCALAPPDATA']
+ else:
+ self.kobodir = os.path.join(os.environ['USERPROFILE'], 'Local Settings', 'Application Data')
+ self.kobodir = os.path.join(self.kobodir, 'Kobo', 'Kobo Desktop Edition')
+ elif sys.platform.startswith('darwin'):
+ self.kobodir = os.path.join(os.environ['HOME'], 'Library', 'Application Support', 'Kobo', 'Kobo Desktop Edition')
+ # desktop versions use Kobo.sqlite
+ kobodb = os.path.join(self.kobodir, 'Kobo.sqlite')
if (self.kobodir != ''):
self.bookdir = os.path.join(self.kobodir, 'kepub')