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 08-17-2018, 12:26 AM   #1
wrench100
Member
wrench100 began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Mar 2018
Device: Kindle
Using wordpress_xmlrpc package in my plugin

I'm writing a plug-in to export book files directly from calibre into a Wordpress site and would like to use the python-zwordpress-xmlrpc package to do it, as it makes wordpress access very easy. (https://python-wordpress-xmlrpc.read....io/en/latest/)

This may be a newbie problem but I'm stuck on how to access the package's functions. I've placed the files in my plug-in folder. They're in a directory called wordpress_xmlrpc which is sitting inside the plugin folder (I'm currently just trying to test them with the interface_demo plugin). In my plug-in code I'm using the following include statements:

from calibre_plugins.interface_demo.wordpress_xmlrpc.ba se import *
from calibre_plugins.interface_demo.wordpress_xmlrpc.wo rdpress import *

But it's not finding the stuff. Help!

Thanks
wrench100 is offline   Reply With Quote
Old 08-17-2018, 01:12 AM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Firstly, it is always a good idea to include the actual error messages produced. That will help to tell us where the error is. For example, I don't know if the import if failing, or if it is when you actually call a method from the packages.

Assuming it is the import failing, have these files been included in the zip file for the plugin? From what you have said, I'm not sure whether you have them in the package, or simply put them in the plugin directory of the calibre preferences.
davidfor is offline   Reply With Quote
Advert
Old 08-17-2018, 01:15 AM   #3
wrench100
Member
wrench100 began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Mar 2018
Device: Kindle
When it launches, it logs the error:

ImportError: No module named wordpress_xmlrpc.base

And yes, I have them in the zip file along with the rest of the plug-in.

Thanks!
wrench100 is offline   Reply With Quote
Old 08-17-2018, 05:11 AM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
That looks like the import then. And it should mean it cannot find the files.

The times I've seen this with a plugin it has either been a spelling mistake in a file somewhere, or the file didn't actually get included in the zip file. Does wordpress_xmlrpc have any dependencies?

The only other thing I can think of is that whenever I have done this, I either use the import form of this, or explicitly name what I want from the module. So, it would be:

Code:
import calibre_plugins.interface_demo.wordpress_xmlrpc.base
from calibre_plugins.interface_demo.wordpress_xmlrpc.wordpress import something_or_other
And looking at the page for the module, I think you should just be using:

Code:
import calibre_plugins.interface_demo.wordpress_xmlrpc
But, you might also need to go through the source of the module and change all the imports to be prefixed with "calibre_plugins.interface_demo.". It might be one of these is failing because it cannot find the file. Just checking one of the plugins I maintain, this is how it works for them.

If you want to attach the plugin, or put it somewhere and PM the link, I can try it over the weekend and hopefully see what is wrong.
davidfor is offline   Reply With Quote
Old 08-17-2018, 08:17 PM   #5
wrench100
Member
wrench100 began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Mar 2018
Device: Kindle
Oh well-done! It took a while to find them all, but once I set all the include paths to be very explicit, it loaded just fine. Thank you so much for your help!
wrench100 is offline   Reply With Quote
Advert
Reply

Tags
modules, packages, plug-ins, wordpress


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] QuickPrefsEdit - Edit plugin prefs json files. slowsmile Plugins 3 07-25-2018 09:14 PM
Goodread Perception Expander plugin not shown on plugin list (kobo h2o) www KOReader 4 09-28-2017 11:34 AM
Problem with my ScrambleEbook plugin and the Plugin Updater tool jackie_w Development 14 01-19-2017 11:49 PM
Multi-plugin package jgoguen Development 5 05-25-2015 05:21 PM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 03:24 AM


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


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