![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
User Interface plugins involving loops
I realise this is a long post but I hope at least someone will find the time to read and offer suggestions...
When writing a new User Interface plugin which involves looping around selected books or looping around files within a book container (or both) I have a decision to make. Should I:
Can anyone offer any general advice on how to go about deciding which option to choose? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
... continued
These are the specifics of my current "fun project" (audiobook creation) in case it makes any decision-making more obvious:
As part of testing I've already coded Options 1 and 2 above with these observations: Option 1: I'm not sure if this is a problem or a feature ![]() Having kicked off the 'Create MP3s' process via button-click it's not obvious how to cancel it. Closing the main dialog looks as if it closes the plugin but the WAV/MP3 creation process seems to keep going in the background. This may be a perfect solution - background running without the coding effort of thread/jobs - but I'm not sure of the technical implications. Option 2: Clicking the QProgressDialog Cancel button may happen during the WAV part or the MP3 part. The user wouldn't know which. ATMO the cancel doesn't take effect until both parts are complete. This could be quite a while after the Cancel button was actually clicked. It would be preferable if part 2 could be skipped if the Cancel button was clicked during part 1. I tried checking for self.wasCanceled() before starting part 2 but with no joy. I'm guessing I'm not understanding event processing well enough. The QProgressDialog pop-up widget is completely empty until the completion of the first do_something cycle. This is a bit unnerving if it's a lengthy first cycle. Is there a way to get self.setLabelText and Cancel button to display immediately? |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,162
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Your choices are:
1) Simply run your entire job in a thread hat produces its output in a temporary directory. Show a blocking progressdialog while this is happening. After the worker thread is complete, copy the output data into calibre on the main thread. 2) Use the calibre jobs infrastructure to do all the heavy lifting for you. This is how calibre itself runs conversion/bulk metadata download etc jobs. The idea is the same, you run the job to output to a temporary dir, when it is complete you bring the data into calibre. I'm sure there must besome existing plugins that use the jobs infrastructure you can copy from. |
![]() |
![]() |
![]() |
#4 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
![]() Is there some calibre help documentation I may have missed that would help me get a better overview of how it all fits together? Quote:
Is there any issue with kicking off multiple MS API calls/EXEs? Might the OS grind to a halt? The end product is a directory full of MP3s on a local disk. I'm not currently planning to import them back into calibre. Is there any need to hide them in a temp dir until the last step? The only output data I might want to bring back to the calibre GUI would be a text log of what was done and how long each cycle took to run. I think I should be able to sort something out for that. |
||
![]() |
![]() |
![]() |
#5 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,162
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Sadly no, I've never got around to documenting the jobs system APIs. Feel free to ask and I will try to help if you get stuck. You only need to use temp dirs if you are working on calibre data, as you must not access the calibre library folder in an asynchronous fashion (for the same reasons you cannot run multiple programs that touch the calibre library)
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Well, I didn't get stuck after all, everything appears to be working OK
![]()
|
![]() |
![]() |
![]() |
#7 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,162
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
1. Its a human readable description of the job that can appear in places like the status bar, jobs list, etc.
2. No idea, that's not from calibre code, is it from a plugin you copied? 3. If it works, dont worry about it. That header appears to imply the file was generated by something called makepy that was itself running on python3, but that may not mean that the generated file actually requires python 3 |
![]() |
![]() |
![]() |
#8 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
![]() This begs a follow-up question. The last arg of that same method is 'in_process' is this also not a part of calibre code? Perhaps I need to examine a few more thread/jobs plugins to see what other redundancies I may be perpetuating. However, I think kiwidude probably wrote most of them so he may have a "house style". |
|
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
|
|
![]() |
![]() |
![]() |
#11 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
And a lot of the comments have been left in the code as I didn't quite know what I was doing at the time I started the plugin. I really do need to do some cleanup. |
|
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Well, I posted this new TTS plugin in the Plugin forum but the call to the MS SAPI speech interface appears to fail if trying to run with calibre 32-bit ... sigh ... I really should have thought to check this before deciding to share.
I don't know enough to be able to fix this, if it even is fixable so I need to be able to fail gracefully, preferably during the initial plugin install, if that's possible. I've set supported_platforms = ['windows'] in the plugin's __init__.py but I don't see anything else obvious in there for checking whether the PC and/or calibre is 64bit. I can see is64bit in calibre.constants, but where is the best place to do the test to cause the least user inconvenience if they don't have a suitable setup? FWIW this was the error message: Spoiler:
Last edited by jackie_w; 06-17-2018 at 06:19 PM. |
![]() |
![]() |
![]() |
#13 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,162
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
As far as I know, there is no way to do the test during installation, as yours is the only plugin I know of that cares about 32/64 bit (most plugins are pure python and so dont need to care). I suggest simply popping up the message when your plugin is clicked if you detect a 32bit environment.
|
![]() |
![]() |
![]() |
#14 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,246
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Thanks.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Questions: Concerning Metadata, Interface, Plugins | Zalbag | Calibre | 6 | 05-26-2018 02:32 AM |
disable unused device interface plugins? | Iskariot | Calibre | 3 | 02-14-2014 06:17 AM |
All user plugins won't install ... | Hoods7070 | Plugins | 6 | 06-11-2012 08:30 AM |
Problems with device interface plugins | adrian1944 | Plugins | 4 | 02-01-2010 11:06 AM |
impserve: user-created plugins and requests.... | nrapallo | Fictionwise eBookwise | 21 | 09-27-2008 09:40 AM |