Had a look at the source code and am I correct in guessing that you hard coded the "
Calibre Library" folder name and that the plugin assumes it's located in the home directory?
I'm not familiar with python nor programming Calibre plugins but I believe there must be a different method of getting the library path(s).
Not sure what the relevant pieces of code are but I think this is probably a good example.
Job Spy/visualize_metadata_dialog.py
Code:
import os,sys,apsw
from PyQt5.Qt import (Qt, QDialog, QGridLayout, QVBoxLayout, QHBoxLayout, QFont,
QWidget, QSize, QPushButton, QComboBox, QGroupBox, QSplitter ) # for visualizing
from PyQt5.Qt import QFileDialog,QObject,QApplication # for exporting a .csv
from calibre import isbytestring
from calibre.constants import filesystem_encoding, DEBUG
from calibre.gui2 import gprefs, question_dialog, info_dialog
from calibre_plugins.job_spy.qpainter_charts import Chart, PieChart, ViewerLegend, ViewerPieChart, DataTable
from calibre_plugins.job_spy.config import prefs
#-----------------------------------------------------------------------------------------
def apsw_connect_to_library(self):
my_db = self.gui.library_view.model().db
path = my_db.library_path
if isbytestring(path):
path = path.decode(filesystem_encoding)
path = path.replace(os.sep, '/')
path = os.path.join(path, 'metadata.db')
path = path.replace(os.sep, '/')
if isbytestring(path):
path = path.decode(filesystem_encoding)
if path.endswith("/"):
path = path[0:-1]
try:
my_db =apsw.Connection(path)
is_valid = True
except Exception as e:
if DEBUG: print("path to metadata.db is: ", path)
if DEBUG: print("error: ", str(e))
is_valid = False
return None,None,is_valid
my_cursor = my_db.cursor()
mysql = "PRAGMA main.busy_timeout = 15000;" #PRAGMA busy_timeout = milliseconds;
my_cursor.execute(mysql)
return my_db,my_cursor,is_valid
P.S.
Forgot to mention earlier that I had to repackage the zip in order to load the plugin (got rid of the top level
KyBook3 Sync directory). Calibre was complaining about
__init__.py not being in the correct location. I'd be happy to help debug but please note I use Calibre Portable and I dunno how to run calibre-debug with that since the paths are all different.