Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 09-09-2016, 11:46 AM   #1
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,969
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Question calibredb set_custom(etc) GUI refresh?

I'm looking through the source for calibredb and noticed that while some commands (add/remove/add_format/etc) send an IPC message to the running GUI to refresh, other commands (set_custom/add_custom/etc) do not. And I can see the difference in the running GUI.

Is using calibredb while the GUI is running: allowed, not allowed, or only allowed for certain commands?

The only reference on the calibredb manual page is the --dont-notify-gui option which implies it is allowed.

The only other reference I've found says "don't do custom columns while GUI is running", but it is quite old.
JimmXinu is offline   Reply With Quote
Old 09-09-2016, 06:53 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can use calibredb while the GUI is running, but it is not a good idea and it's likely the ability will be removed in the future in favor of a direct IPC interface to the db the GUI is using. Adding/modifying custom columns requires a GUI restart, which is why calibre db does not notify the GUI on those actions, while adding/deleting/etc. works fine witha simple refresh in the GUI.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-09-2016, 09:05 PM   #3
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,969
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
So add_custom_column and remove_custom_column are definitely GUI-unsafe--not surprising.

Judging by which commands update the DB but don't call send_message, the commands set_metadata and set_custom are also GUI-unsafe?

(If calibredb as it is now is going to be around for a while, I'd suggest adding notes to the manual page about which options aren't safe while the GUI is running.)
JimmXinu is offline   Reply With Quote
Old 09-10-2016, 10:01 AM   #4
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
Calibredb: Backward Compatibility

Quote:
Originally Posted by kovidgoyal View Post
You can use calibredb while the GUI is running, but it is not a good idea and it's likely the ability will be removed in the future in favor of a direct IPC interface to the db the GUI is using. Adding/modifying custom columns requires a GUI restart, which is why calibre db does not notify the GUI on those actions, while adding/deleting/etc. works fine witha simple refresh in the GUI.

Kovid,

I know that you put a great premium on backward compatibility of fundamental changes to Calibre, so I would like to state that I have several plug-ins that use calibredb to automatically create new Custom Columns for the user in order for them to continue.
  • CALM - Consolidate All Library Metadata
  • ZMI - Zotero Metadata Importer
  • LC - Library Codes
ZMI creates its standard set of 27 Custom Columns using calibredb, then automatically restarts Calibre.

CALM creates (potentially hundreds of) Custom Columns using calibredb in a CALM Target Library that is never the current Library, although of course the GUI is running for the current Library since CALM is being used. No restart is needed when calibredb updates an "offline" Library even if the GUI is running for a different Library.

LC creates user-selected Custom Columns, then does what Calibre itself does in Preferences > Add your own columns: the user is told that they must manually restart Calibre for the changes to take effect.

Thousands of Calibre Users would be impacted by any non-backward-compatible changes to calibredb.


Thanks for your consideration.


DaltonST
DaltonST is offline   Reply With Quote
Old 09-12-2016, 07:38 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@JimmXinu: set_custom and set_metadata dont operate ont he db so there is no question of notifying the GUI

@DaltonST: The correct way for a plugin to access/modify the db is to use the python db apis, not calibredb. However, as I said in my original post, the current design of calibredb which opens the database separately will be replaced by one that connects to a running instance of the calibre GUI/calibre server via IPC to perform its actions. So adapting your plugins would be as simple as passing in an extra parameter such as

--use-running-server

to calibredb.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-12-2016, 08:52 AM   #6
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by DaltonST View Post
Kovid,

I know that you put a great premium on backward compatibility of fundamental changes to Calibre, so I would like to state that I have several plug-ins that use calibredb to automatically create new Custom Columns for the user in order for them to continue.
And as has been observed multiple times, don't do that.

Why are you using the command-line-shell wrapper around the db interface, rather than using the currently open db interface directly from python?

You are adding a great deal of complexity, and additionally making your plugins unreliable or outright broken for some of your users.
With zero benefit whatsoever.

Although you have invented a novel way to misuse calibre.

Last edited by eschwartz; 09-12-2016 at 09:18 PM. Reason: typo
eschwartz is offline   Reply With Quote
Old 09-12-2016, 09:04 AM   #7
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,969
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by kovidgoyal View Post
@JimmXinu: set_custom and set_metadata dont operate on the db so there is no question of notifying the GUI
??? They don't change the schema, but they certainly change values in the db. And I apparently misread the code--set_metadata does send the GUI the refresh message.

It looks to me more like set_custom should also send the refresh IPC message to the GUI. The change is quite small, I can make a PR if you like.

Code:
diff --git a/src/calibre/library/cli.py b/src/calibre/library/cli.py
index 759c775..a996806 100644
--- a/src/calibre/library/cli.py
+++ b/src/calibre/library/cli.py
@@ -1065,6 +1065,8 @@ def command_set_custom(args, dbpath):
         return 1
     do_set_custom(get_db(dbpath, opts), args[0], int(args[1]), args[2],
             opts.append)
+    write_dirtied(db)
+    send_message()
     return 0
Not that the change will make it perfect--the same sort of race conditions that require GUI PIs to use proceed_question will still be possible.
JimmXinu is offline   Reply With Quote
Old 09-12-2016, 08:52 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Sorry, I was thinking of something else (handling too much piled up email yesterday

Yes, they should be notifying the GUI.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forcing Total Cache & GUI Refresh Without Restarting DaltonST Development 13 09-18-2014 04:29 PM
Option for 'calibredb' to *not* notify a running Calibre GUI? mbovenka Development 4 11-08-2012 04:30 AM
calibredb remove ... BerlinerKindl Library Management 6 11-25-2011 09:24 PM
calibredb iomari Calibre 6 10-10-2011 08:35 AM
calibredb set_custom GUI question Sabkor Library Management 4 03-12-2011 08:51 PM


All times are GMT -4. The time now is 12:04 PM.


MobileRead.com is a privately owned, operated and funded community.