Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 10-25-2012, 11:58 AM   #1
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,710
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Help viewing calibre gui data via commandline

I am trying to get a better understanding of the calibre library data available when creating a typical user interface plugin. Please could someone get me started.

As an example, some simple code I already have in a working plugin is this:
Code:
db = self.gui.library_view.model().db
book_authors = db.authors(book_id, index_is_id=True)
where book_id is a known value.

If I want to create that gui db object in a commandline session (either interactive or in a script.py file) so I can poke around a little (viewing only) what do I need to do?

I've seen the calibre-debug -e myscript.py option in the user manual but I'm not sure how to access the gui data.

Secondly, if the above is possible I would also like to look around the available data when a device is connected (self.gui.device_manager.connected_device when used in a plugin).

In case it's relevant, I don't have any development environment - just my trusty text editor (Notepad++)
jackie_w is offline   Reply With Quote
Old 10-25-2012, 01:04 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: 25,453
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre-debug -c "from calibre.library import db; db = db(); Do whatever with the db object"

For device access, you can directly instaantiate the device plugin, like this

calibre-debug -c "from calibre.customize.builtins import PRS505; device = PRS505(None)"
kovidgoyal is online now   Reply With Quote
 
Enthusiast
Old 10-25-2012, 01:59 PM   #3
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,710
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Many thanks, I'll have a play
jackie_w is offline   Reply With Quote
Old 10-25-2012, 08:26 PM   #4
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,710
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
After some playing around I'm OK with the 'db' part of your reply but not the 'device' part. I understand, using your example, that I can do things like
Code:
device=PRS505(None)
print(device.EBOOK_DIR_MAIN)
to view some variables, but if I want to be able to examine other device data available whilst the device is actually connected to my PC, what extra do I need to do?
e.g within a plugin, if I wanted to know what drive the device was connected as I would use
Code:
root_path = self.gui.device_manager.connected_device._main_prefix
what extras would I need to import to be able to access this data via the commandline?
jackie_w is offline   Reply With Quote
Old 10-25-2012, 11:24 PM   #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: 25,453
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Call device.open((1,1,1,'','',''), 'test') then calibre will connect to the device and you will be able to interrogate the device.
kovidgoyal is online now   Reply With Quote
Old 10-26-2012, 09:53 AM   #6
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,710
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Thank you, that works. The fog is lifting...
jackie_w is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre is not viewing Arabic text ahmed_rdi Calibre 3 10-19-2011 04:42 AM
deleting old news via commandline?! gdm11 Calibre 1 06-12-2011 07:33 PM
PRS-650 First Checkout from Overdrive - Viewing in Calibre? ArmadilloPilot Sony Reader 5 02-18-2011 02:00 PM
Series data usage, and GUI manipulations? DSchaper Calibre 1 01-17-2011 08:10 PM
Commandline only build plord Calibre 11 11-27-2010 06:56 PM


All times are GMT -4. The time now is 03:03 AM.


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