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-16-2014, 01:22 PM   #1
edward.81
Junior Member
edward.81 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jul 2014
Device: Moonreader (android)
Plugin test with mtp

Just doing some experiment but i get a little confused from this:
Code:
from calibre.devices.mtp.driver import MTP_DEVICE

class MYSYNC(MTP_DEVICE):
    name                = 'Android Sync' # Name of the plugin
    description         = 'bla bla bla'
    supported_platforms = ['windows', 'linux'] # Platforms this plugin will run on
    author              = 'dontlookhere' # The author of this plugin
    version             = (0, 1, 0)   # The version number of this plugin
    minimum_calibre_version = (0, 7, 53)
This is the little code. I try to make a plugin that extend mtp for my device. I don't know is is possible but if i try to load the plugin:

calibre-customize -b mine/

I get this error:
Code:
Traceback (most recent call last):
  File "/usr/bin/calibre-customize", line 20, in <module>
    sys.exit(main())
  File "/usr/lib/calibre/calibre/customize/ui.py", line 662, in main
    build_plugin(opts.build_plugin)
  File "/usr/lib/calibre/calibre/customize/ui.py", line 624, in build_plugin
    plugin = add_plugin(t.name)
  File "/usr/lib/calibre/calibre/customize/ui.py", line 382, in add_plugin
    'A builtin plugin with the name %r already exists' % plugin.name)
calibre.customize.ui.NameConflict: A builtin plugin with the name u'MTP Device Interface' already exists
I'm doing something wrong ? I have my ""luck"" has found a bug?
edward.81 is offline   Reply With Quote
Old 08-17-2014, 01:24 AM   #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: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot inherit from a builtin driver class like that. The plugin loading system has no way to know which is the driver class, MTP_DEVICE or MSYNC

You need to inherit from the DevicePlugin class instead.

If you really want to inherit from MTP_DEVICE then create a driver.py file in your plugin and do it in that, then simply import MSYNC into __init__.py like this

from calibre_plugins.my_plugin_import_name.driver import MSYNC
kovidgoyal is offline   Reply With Quote
Advert
Old 08-17-2014, 02:00 AM   #3
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: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
And this commit should allow your __init__.py to work as well

https://github.com/kovidgoyal/calibr...a9f681b2234426
kovidgoyal is offline   Reply With Quote
Old 08-17-2014, 04:32 AM   #4
edward.81
Junior Member
edward.81 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jul 2014
Device: Moonreader (android)
Quote:
Originally Posted by kovidgoyal View Post
You cannot inherit from a builtin driver class like that. The plugin loading system has no way to know which is the driver class, MTP_DEVICE or MSYNC

You need to inherit from the DevicePlugin class instead.

If you really want to inherit from MTP_DEVICE then create a driver.py file in your plugin and do it in that, then simply import MSYNC into __init__.py like this

from calibre_plugins.my_plugin_import_name.driver import MSYNC
Got it thanks !

Quote:
Originally Posted by kovidgoyal View Post
And this commit should allow your __init__.py to work as well

https://github.com/kovidgoyal/calibr...a9f681b2234426
Simply awesome !
edward.81 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Abiword v3.0 ePub plugin output test Doitsu ePub 0 05-10-2014 10:28 AM
Build 1.2 MTP support Patricia1066 Calibre 3 09-06-2013 07:29 PM
Windows 8 MTP Problems CardcaptorRLH85 Devices 2 12-07-2012 01:03 AM
Thank you for MTP support blak4dr Calibre 3 09-22-2012 10:08 PM
MTP support: Testers needed kovidgoyal Calibre 68 09-21-2012 03:54 AM


All times are GMT -4. The time now is 08:44 PM.


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