Publish Errors
  • Hello,

    After a very rocky installation I now have Booktype 2.0 running on Ubuntu 14.04.


    When I try and publish, Celery picks up and execute the job but encounters one of two errors (depending on the type of output requested). For PDF, I end up with a PDF file containing the title and TOC, but no copy text and the following errors:


    [2015-10-21 15:10:13,773: INFO/MainProcess] Received task: booktype.apps.edit.tasks.publish_book[5bcabf4c-a1f3-433d-9e9f-52c371df6b32]
    [2015-10-21 15:10:13,801: INFO/MainProcess] Received task: convert[0b42660a-9e7e-4997-8167-332081c20d85]
    [2015-10-21 15:10:14,271: INFO/MainProcess] Received task: convert_one[mpdf:f0489729-088d-4939-9e98-1e0da39a4cdc]
    [2015-10-21 15:10:14,280: WARNING/Worker-10] /usr/local/lib/python2.7/dist-packages/celery/result.py:45: RuntimeWarning: Never call result.get() within a task!
    See http://docs.celeryq.org/en/latest/userguide/tasks.html#task-synchronous-subtasks

    In Celery 3.2 this will result in an exception being
    raised instead of just being a warning.

    warnings.warn(RuntimeWarning(E_WOULDBLOCK))

    [2015-10-21 15:10:14,288: WARNING/Worker-9] /usr/local/src/booktype/lib/booktype/utils/misc.py:404: RuntimeWarning: Argument is not an unicode object. Passing an encoded string will likely have unexpected results.
    text = unidecode.unidecode(text)

    [2015-10-21 15:10:15,016: INFO/Worker-9] Conversion lasted 0:00:00.738524.
    [2015-10-21 15:10:15,029: INFO/MainProcess] Task convert_one[mpdf:f0489729-088d-4939-9e98-1e0da39a4cdc] succeeded in 0.756924312002s: {'output':...
    [2015-10-21 15:10:15,303: INFO/MainProcess] Task convert[0b42660a-9e7e-4997-8167-332081c20d85] succeeded in 1.495518373s: {u'mpdf:f0489729-088d-4939-9e98-1e0da39a4cdc': }
    [2015-10-21 15:10:15,405: INFO/MainProcess] Task booktype.apps.edit.tasks.publish_book[5bcabf4c-a1f3-433d-9e9f-52c371df6b32] succeeded in 1.632006408s: None

    When choosing EPUB, MOBI or XHTML I get an error reporting back with no file available and the following errors in the Celery log:


    [2015-10-21 15:11:53,267: INFO/MainProcess] Received task: booktype.apps.edit.tasks.publish_book[4124adbb-7526-46a8-96d2-90f5081e0314]
    [2015-10-21 15:11:53,294: INFO/MainProcess] Received task: convert[47ad2b19-b766-4458-8cd1-3f1459441ad8]
    [2015-10-21 15:11:53,736: INFO/MainProcess] Received task: convert_one[epub:174c40f1-ed04-4d01-a700-f5bc6ab309ff]
    [2015-10-21 15:11:53,891: ERROR/MainProcess] Task convert_one[epub:174c40f1-ed04-4d01-a700-f5bc6ab309ff] raised unexpected: Error(None,)
    Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
    File "/usr/local/src/booktype/lib/booktype/apps/convert/tasks.py", line 49, in decorated_func
    return func(request, *args, **kwargs)
    File "/usr/local/src/booktype/lib/booktype/apps/convert/tasks.py", line 65, in convert_one
    result = run_conversion(*args, **kwargs)
    File "/usr/local/src/booktype/lib/booktype/convert/runner.py", line 58, in run_conversion
    conversion_result = converter.convert(book, output)
    File "/usr/local/src/booktype/lib/booktype/convert/epub/converter.py", line 147, in convert
    epub_writer.process()
    File "/home/ubuntu/src/ebooklib/ebooklib/epub.py", line 559, in process
    plg.html_before_write(self.book, item)
    File "/usr/local/src/booktype/lib/booktype/convert/epub/writerplugin.py", line 40, in html_before_write
    root = ebooklib.utils.parse_html_string(item.content)
    File "/home/ubuntu/src/ebooklib/ebooklib/utils.py", line 39, in parse_html_string
    html_tree = html.document_fromstring(s , parser=utf8_parser)
    File "/usr/local/lib/python2.7/dist-packages/lxml/html/__init__.py", line 614, in document_fromstring
    value = etree.fromstring(html, parser, **kw)
    File "lxml.etree.pyx", line 3103, in lxml.etree.fromstring (src/lxml/lxml.etree.c:70569)
    File "parser.pxi", line 1828, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:106403)
    File "parser.pxi", line 1716, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:105194)
    File "parser.pxi", line 1086, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:99876)
    File "parser.pxi", line 580, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:94350)
    File "parser.pxi", line 690, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:95786)
    File "parser.pxi", line 631, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:95065)
    XMLSyntaxError: None
    [2015-10-21 15:11:54,262: INFO/MainProcess] Task convert[47ad2b19-b766-4458-8cd1-3f1459441ad8] succeeded in 0.967212782001s: {u'epub:174c40f1-ed04-4d01-a700-f5bc6ab309ff': }
    [2015-10-21 15:11:54,374: INFO/MainProcess] Task booktype.apps.edit.tasks.publish_book[4124adbb-7526-46a8-96d2-90f5081e0314] succeeded in 1.105724427s: None

    Is this likely a bug or configuration issue?


    Thanks in advance.

    Post edited by Andy Buckingham at 2015-10-21 10:25:09
  • 2 Comments sorted by
  • Sorry not an answer.

    I have a similar problem.

    After a publish, no pdf but this message in /var/www/booktype/instance1/logs/booktype-celery.error.log :

    INFO/MainProcess] Received task: booktype.apps.edit.tasks.publish_book[3a4bcae8-d70d-4d63-92b1-b2fd9c734d3a]
    [2015-10-26 14:24:32,715: ERROR/Worker-2] Could not load URL /_convert/.
    Traceback (most recent call last):
    File "/var/lib/booktype/lib/booktype/apps/edit/tasks.py", line 44, in fetch_url
    r = urllib2.urlopen(req)
    File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
    File "/usr/lib/python2.7/urllib2.py", line 396, in open
    protocol = req.get_type()
    File "/usr/lib/python2.7/urllib2.py", line 258, in get_type
    raise ValueError, "unknown url type: %s" % self.__original
    ValueError: unknown url type: /_convert/
    [2015-10-26 14:24:32,716: ERROR/Worker-2] Could not fetch the book from [/_convert/]

    An idea anyone ?

    PhA
  • Hi PhA!

    It is trying to communicate with the publishing engine. It thinks that publishing engine is at URL "/_convert/" and that is wrong, because hostname is missing.

    Check your dev.py or prod.py settings file and check the value of this option: THIS_BOOKTYPE_SERVER. If yo are hosting it at 192.168.1.2 and port 8000 it should be:
    THIS_BOOKTYPE_SERVER='192.168.1.2:8000' and if you are hosting it at bk.myserver.com over port 80, it should be
    THIS_BOOKTYPE_SERVER='bk.myserver.com'.

    After that, you should check that you have:
    BOOKTYPE_URL = 'http://{}'.format(THIS_BOOKTYPE_SERVER)
    CONVERT_URL = BOOKTYPE_URL

    This is written by default. After this changes it should be able to construct correct url like http://bk.myserver.com/_convert/ or whatever.

    Also, check that you have in base.py
    EXPORT_ALLOWED_HOSTS = ['127.0.0.1', '*']

    This is not safe, but you can do it just to make it work for now.

    Aco