Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 09-24-2011, 09:07 AM   #1
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
Cli-usage in plugins

I would like to use the command line interface of calibre in one of my plugins.
Is there a posibility to do so?

The idea is to create a plugin that can perform multiple-database actions (like syncing of some data).

Edit:
In the manual I found information about the cli and about plugin creation, but not about howto execute cli-tasks via plugins.

Last edited by drMerry; 09-24-2011 at 09:09 AM.
drMerry is offline   Reply With Quote
Old 09-24-2011, 09:39 AM   #2
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
I see absolutely no point in what you're asking. A plugin has full access to the API and can call the required functionality programatically. What exactly do you want to do with the db calls?
user_none is offline   Reply With Quote
Advert
Old 09-24-2011, 09:53 AM   #3
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
Hmm, so all functions in the cli are available by the API.
I'll look at it.

What I'm planning to do is e.g. requesting columns from the current database and from a remote database.
So I can display them and show the differences with the option to sync (saying update data in one of the databases or add column in remote database.
drMerry is offline   Reply With Quote
Old 09-24-2011, 12:03 PM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by drMerry View Post
What I'm planning to do is e.g. requesting columns from the current database and from a remote database.
So I can display them and show the differences with the option to sync (saying update data in one of the databases or add column in remote database.
That will require you to have two libraries open at the same time, or at least to switch libraries in the middle of processing. I don't see any way to do that using calibre's API without a world of hurt.

You would probably be better off writing your own query programs that produce output in some known format such as CSV. You would use python's os.system() API to execute the query on the read-only library, and calibre's API to get the info for the read/write library. Or something like that.
chaley is offline   Reply With Quote
Old 09-24-2011, 01:46 PM   #5
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
hmmmm...

I was thinking of using the cli.
the cli interface has some options to set and get information from the database.
So I would use calibre for the current db and get / set (some) info of the other database using calibre-cli
drMerry is offline   Reply With Quote
Advert
Old 09-24-2011, 01:48 PM   #6
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,188
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no need to use the cli, just create a new LibraryDatabse2 object to connect to the other library. See for example the code in actions.copy_to_library
kovidgoyal is offline   Reply With Quote
Old 09-24-2011, 01:49 PM   #7
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
of course I could wirte another app, but the nice thing is to have it integrated in calibre.

If I want my own app to be integrated in calibre, I can see 3 ways:
1. Starting my app by calibre using a cli-command
2. Starting my app by user before or during calibre
3. Run my app seperately from calibre

Oprion 2 and 3 are not user friendly. Option 1 will need the same function as requested in first post
drMerry is offline   Reply With Quote
Old 09-24-2011, 01:50 PM   #8
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
Typing together

Quote:
Originally Posted by kovidgoyal View Post
There is no need to use the cli, just create a new LibraryDatabse2 object to connect to the other library. See for example the code in actions.copy_to_library
hmmm sounds promising.

I'll take a look, thanks.
drMerry is offline   Reply With Quote
Old 09-24-2011, 03:58 PM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Note that some parts of calibre assume that there is one library open. Two I can think of are user-define template functions and saved searches. There are probably others.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing built in recipes via CLI? jbmia Recipes 7 07-22-2011 02:25 PM
Add book by CLI plalloni Library Management 3 03-01-2011 04:15 PM
Struggling with CLI Paulinafrica Calibre 4 01-08-2011 02:04 PM
Adding online metadata using ISBN from CLI EditorJack Calibre 17 01-20-2009 01:47 AM
prs505 cli ees Calibre 3 01-10-2009 03:27 AM


All times are GMT -4. The time now is 02:39 PM.


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