![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Oct 2012
Device: none
|
Help with plugin dev.
Hi,
I need some help with plugin development. Firstly, I'm not familiar with the intricacies of Python but I can't get any debugging output to appear using print, write or anything else, based on the suggestions in the plugin dev. pages on the calibre site. Not a character. I've stuck statements all over the code in places that are definitely being hit. What am I doing wrong? Do I need to redirect output somewhere specific. I'm running from the console using calibre-debug. Secondly, I want to have my plugin generate its own cover and use it with the book it creates. I have that working but I can't find any way to prevent the default background texture from being drawn (which, I agree with comments elsewhere, isn't particularly nice). I've gone as far as to d/l the source and find where it's added but nothing I do anywhere stops it appearing. I've overridden the relevant functions, thus: def calibre_cover(title, author_string, series_string=None, output_format='jpg', title_size=46, author_size=36, logo_path=None): title = normalize(title) author_string = normalize(author_string) series_string = normalize(series_string) # from calibre.utils.magick.draw import create_cover_page, TextLine from calibre.utils.magick.draw import TextLine lines = [TextLine(title, title_size), TextLine(author_string, author_size)] if series_string: lines.append(TextLine(series_string, author_size)) if logo_path is None: logo_path = I('library.png') return self.create_cover_page(lines, logo_path, output_format='jpg', texture_opacity=0.3, texture_data=I('add_book.png', data=False)) def create_cover_page(top_lines, logo_path, width=590, height=750, bgcolor='#ffffff', output_format='jpg', texture_data=None, texture_opacity=1.0): ''' Create the standard calibre cover page and return it as a byte string in the specified output_format. ''' canvas = create_canvas(width, height, bgcolor) if texture_data and hasattr(canvas, 'texture'): texture = Image() texture.load(texture_data) texture.set_opacity(texture_opacity) canvas.texture(texture) bottom = 10 for line in top_lines: twand = create_text_wand(line.font_size, font_path=line.font_path) bottom = draw_centered_text(canvas, twand, line.text, bottom) bottom += line.bottom_margin bottom -= top_lines[-1].bottom_margin foot_font = tweaks['generate_cover_foot_font'] if not foot_font: foot_font = P('fonts/liberation/LiberationMono-Regular.ttf') vanity = create_text_arc(__appname__ + ' ' + __version__, 24, font=foot_font, bgcolor='#00000000') lwidth, lheight = vanity.size left = int(max(0, (width - lwidth)/2.)) top = height - lheight - 10 canvas.compose(vanity, left, top) available = (width, int(top - bottom)-20) if available[1] > 40: logo = Image() logo.open(logo_path) lwidth, lheight = logo.size scaled, lwidth, lheight = fit_image(lwidth, lheight, *available) if scaled: logo.size = (lwidth, lheight) left = int(max(0, (width - lwidth)/2.)) top = bottom+10 extra = int((available[1] - lheight)/2.0) if extra > 0: top += extra canvas.compose(logo, left, top) return canvas.export(output_format) I tried just using calibre_cover first and changing the values in the call to create_cover_page. Then I tried replacing create_cover_page. The thing just fails to use my cover at all and generates the default version,. I'm probably doing something silly but what? I've tried everything I can think of in the recipe and in main.py, including setting texture_data to none, changing opacity, disabling function calls, attempting to use a different texture as above, etc. Nothing works. My plugin works well otherwise so it is called, it runs, it outputs, it's updated between runs, it lives and breathes and I disabled the related imports. It's more likely to be my lack of knowledge re: python and calibre, than something procedural. If we can fix point 1 that will undoubtedly help with point 2. Thanks. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,200
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you're developing a conversion plugin its output will be available in the conversion log. Click the rotating spinner in the bottom right to get the conversion log.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Oct 2012
Device: none
|
Thanks. Ain't it always the way, after banging away for hours making no progress and making this request, the next day I was able to get it all working. I was very tired when I was first working on it and I think I missed one or two things. The plugin is here.
Cheers. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modify ePub plugin dev thread | kiwidude | Development | 346 | 09-02-2013 05:14 PM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 02:24 AM |
Einfacher Feature-Request: /dev/ptmx und /dev/ttyUSB2 modes | Seneca | PocketBook | 2 | 12-05-2011 04:41 PM |
Another plugin dev question | DiapDealer | Plugins | 2 | 12-11-2010 01:46 PM |
Epub plugin dev | DiapDealer | Plugins | 15 | 11-12-2010 09:36 AM |