![]() |
#1 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
calibre.utils.ipc RC Removed in 5.7? Replacement?
Code:
from calibre.utils.ipc import RC ... ... t = RC(print_error=False, socket_address=self.gui_socket_address) t.start() t.join(3) if t.done: msg = 'refreshdb: ' t.conn.send(msg) t.conn.close() In Calibre 5.7, MFI fails at Calibre startup because RC no longer exists to be imported from calibre.utils.ipc . Would there be a replacement for RC that can be used to perform the identical function in Calibre 5.7? Thanks. DaltonST |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
See calibre.gui2.listener
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
IPC message 'refreshdb:' no longer exists in Calibre 5.7
Unfortunately, the message 'refreshdb: ' no longer exists in Calibre 5.7.
Is there a way to get the same result as in Calibre 5.6? DaltonST |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, since you are not allowed to open a calibre database in multiple programs simultaneously, there is no longer any need for that function.
|
![]() |
![]() |
![]() |
#5 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
So if a GUI plugin exrcutes a db.add_book() many times quickly, how does it now (5.7) notify Calibre to update the Cache from the physical DB so that the library_view can be subsequently updated from the refreshed Cache? That is the very real problem. 5.6 could do that. 5.7 now requires a Calibre restart to show the new books, which is unacceptable.
I tried using the "bookedit:" message in a loop for each new book_id, but the Listener refuses the connection because it sources from an unknown server. Is a GUI plugin now considered a different program? |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you want to refresh the book list from a GUI plugin, you dont need to use IPC. Refreshing the book list is trivial to do, look at any number of plugins that do it or look at for instance how the builtin edit metadata action does it.
I have no clue why you were using IPC to refresh the GUI in your GUI plugin. GUI plugins run the in the same process as the rest of the GUI and should ever need to use IPC to communicate with it. |
![]() |
![]() |
![]() |
#7 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
You misunderstand.
It is trivial to refresh the Library View from the Cache, but only if the Cache itself has just been refreshed from metadata.db. I was reloading the book ids from the physical SQLite database into the Cache by using the "refreshdb:" IPC message that no longer exists in Calibre 5.7. Hard-drive to Cache, not Cache to GUI Library View. Added: History: I began to use IPC to refresh the Cache after you deprecated using "calibredb --add-books" while the current Calibre Library GUI was running. It was so easy with "calibredb --add-books". I will try this next: Code:
class ResultCache(SearchQueryParser): def refresh_ids(self, db, ids): ''' Refresh the data in the cache for books identified by ids. Returns a list of affected rows or None if the rows are filtered. ''' for id in ids: try: self._data[id] = CacheRow(db, self.composites, self.datetimes, db.conn.get('SELECT * from meta2 WHERE id=?', (id,))[0], self.series_col, self.series_sort_col) self._data[id].append(db.book_on_device_string(id)) self._data[id].append(self.marked_ids_dict.get(id, None)) self._data[id].append(None) self._uuid_map[self._data[id][self._uuid_column_index]] = id except IndexError: return None try: return list(map(self.row, ids)) except ValueError: pass return None Last edited by DaltonST; 12-13-2020 at 11:39 AM. Reason: History: calibredb --add-books |
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Let me repeat, you are not supposed to be accessing the database in ANYTHING other than the calibre process, using the calibre database API. If you do so, you will break things, and you are on your own. Good luck. If you think you are going to be able to manipulate the database out from under calibre and then somehow successfully refresh the in-memory view of the database that calibre has, I'm afraid you have another think coming.
|
![]() |
![]() |
![]() |
#9 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
And although I remember you ignored me the first time around as well, let me link to you teh CORRECT way to add books, if only for the sake of the poor users whose databases you are going to end up breaking.
https://manual.calibre-ebook.com/db_...ache.add_books |
![]() |
![]() |
![]() |
#10 | |||
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
Kovid, Let me remind you of my previous post above:
Quote:
I am now using self.maingui.library_view.model().refresh(), instead of .refresh_ids(ids), which solves my problem of not using IPC any longer. Works fine. Quote:
Quote:
Thank you for your kind advice, although it clearly was meant for someone other than me. DaltonST Last edited by DaltonST; 12-16-2020 at 11:16 AM. Reason: Clarification |
|||
![]() |
![]() |
![]() |
#11 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,208
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
I have a GUI plugin that uses refresh_ids(ids), but I also use another parameter to refresh the Book Details Panel for the currently selected book: Code:
self.gui.library_view.model().refresh_ids(ids, current_row=self.gui.library_view.currentIndex().row()) |
|
![]() |
![]() |
![]() |
#12 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The canonical way to refresh the GUI after adding books, is the way calibre does it itself, which is:
Code:
self.gui.iactions['Add Books'].refresh_gui(num_of_books_added) |
![]() |
![]() |
![]() |
#13 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,208
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
But this raised another question for me. When I use the refresh_ids method (with current_row argument), the last added book gets selected and everything is refreshed for that book (including Quick View, by using qv.refresh_quickview(current)). But when I use the canonical way, after all books are added, the current book is still the same as before the adding action. Also, Quick View does not update*, even if a new book that affects it was added). * To refresh it, I have to click on another book and then go back to the previously selected book. |
|
![]() |
![]() |
![]() |
#14 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,322
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you want the last added book to be selected, pass set_current_row=row_number to that function.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kobo Utils and new Calibre | Stevex | Kobo Reader | 4 | 09-03-2020 02:19 PM |
IPC between plugin and interface | Sytten | Development | 5 | 05-10-2020 11:56 PM |
PBTouchLux3: Series removed in Calibre, still on reader | bluesorella | PocketBook | 1 | 09-03-2016 12:07 PM |
linux-utils (k3 and beyond) | twobob | Kindle Developer's Corner | 4 | 11-19-2013 10:26 AM |
xdg-utils should be listed as a debian build-dep? | twobob | Calibre | 4 | 10-16-2013 04:16 AM |