Opened 3 years ago
Closed 11 months ago
#14087 closed defect (fixed)
Missing 'trac_auth' cookie in request
Reported by: | Owned by: | Cinc-th | |
---|---|---|---|
Priority: | normal | Component: | TracWikiPrintPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.4 |
Description
After installing the plugin, trying to print a wiki page results in a KeyError: 'trac_auth'.
Systeminformation: User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0 Paket Version Trac 1.4.1 Babel 2.8.0 Docutils 0.16 Genshi 0.7.3 (with speedups) Jinja2 2.11.2 mod_python 3.3.1 MySQL server: "5.7.21-1ubuntu1", client: "0.9.3", thread-safe: True Pygments 2.5.2 pymysql 0.9.3 Python 2.7.18 (default, Mar 8 2021, 13:02:45) [GCC 9.3.0] pytz 2020.1 setuptools 44.1.0 Subversion 1.13.0 (r1867053) Textile 3.0.4 jQuery 1.12.4 jQuery UI 1.12.1 jQuery Timepicker 1.6.3 Installierte Plugins Name Version Ort TracCsvPlugin 0.0.1 /usr/local/lib/python2.7/dist-packages/TracCsvPlugin-0.0.1-py2.7.egg TracDragDrop 0.12.0.15 /usr/local/lib/python2.7/dist-packages/TracDragDrop-0.12.0.15-py2.7.egg TracNav 4.1 /usr/local/lib/python2.7/dist-packages TracPdfPreview 0.1.2 /usr/local/lib/python2.7/dist-packages TracPlantUml 2.3 /usr/local/lib/python2.7/dist-packages TracTags 0.12.dev0 /usr/local/lib/python2.7/dist-packages TracWikiAutoComplete 1.4 /usr/local/lib/python2.7/dist-packages/TracWikiAutoComplete-1.4-py2.7.egg TracWikiExtras 1.3.1 /usr/local/lib/python2.7/dist-packages TracWikiPrint 4.0.0.dev0 /usr/local/lib/python2.7/dist-packages/TracWikiPrint-4.0.0.dev0-py2.7.egg TracXMLRPC 1.1.9.dev0 /usr/local/lib/python2.7/dist-packages
Attachments (1)
Change History (29)
Changed 3 years ago by
Attachment: | 2021-12-02_00-08.png added |
---|
comment:1 Changed 3 years ago by
comment:2 Changed 3 years ago by
Component: | TracWikiToPdfPlugin → TracWikiPrintPlugin |
---|---|
Keywords: | cookie auth print tracwikitopdfplugin removed |
Owner: | set to Cinc-th |
Priority: | high → normal |
Severity: | critical → normal |
The error is raised from TracWikiPrintPlugin.
comment:3 Changed 2 years ago by
Hi, I have the same issue as his. Moreover, this issue has been appeared when I use Ldap authentication and authorization like that:
<Location /prt/prj> WSGIApplicationGroup %{GLOBAL} SSLRequireSSL Allow from 10.0.0.0/24 AuthType Basic AuthName "Protected" AuthBasicProvider "ldap" AuthLDAPURL "ldap://192.168.1.1/dc=example,dc=com?mail?sub?(&(objectClass=*)(accountstatus=active)(mail=*@example.com))" AuthLDAPBindDN "cn=manager,dc=example,dc=com" AuthLDAPBindPassword "password" Require valid-user </Location> </VirtualHost>
but when I use another configuration everything is alright
<Location /pub/prj> SSLRequireSSL WSGIApplicationGroup %{GLOBAL} </Location> <LocationMatch /pub/prj/[[:alnum:]_]+/login> Allow from 10.0.0.0/24 AuthType Basic AuthName "Public area" AuthBasicProvider "ldap" AuthLDAPURL "ldap://192.168.1.1/dc=example,dc=com?mail?sub?(&(objectClass=*)(accountstatus=active)(mail=*@example.com))" AuthLDAPBindDN "cn=manager,dc=example,dc=com" AuthLDAPBindPassword "password" Require valid-user </LocationMatch>
These options are very different. The former requires authorization before the user can access the protected area, the latter has access for anonymous users and the user can log in with their username and password.
Python Traceback
Most recent call last: File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 639, in dispatch_request dispatcher.dispatch(req) File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 250, in dispatch resp = chosen_handler.process_request(req) File "/usr/local/lib/python2.7/dist-packages/trac/wiki/web_ui.py", line 186, in process_request format, versioned_page.name) File "/usr/local/lib/python2.7/dist-packages/trac/mimeview/api.py", line 1020, in send_converted iterable=iterable) File "/usr/local/lib/python2.7/dist-packages/trac/mimeview/api.py", line 705, in convert_content conversion.key) File "/usr/local/lib/python2.7/dist-packages/tracpdf/wikiprint.py", line 218, in convert_content pdfoptions = self.prepare_pdf_options(req, pagename) File "/usr/local/lib/python2.7/dist-packages/tracpdf/wikiprint.py", line 261, in prepare_pdf_options ('trac_auth', req.incookie['trac_auth'].value),
my system info
System Information User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.49 Package Version Trac 1.4.3 Genshi 0.7.3 (with speedups) Jinja2 2.11.3 mod_wsgi 4.3.0 (WSGIProcessGroup wsgitrac_protected WSGIApplicationGroup %{GLOBAL}) pysqlite 2.6.0 Python 2.7.12 (default, Mar 1 2021, 11:38:31) [GCC 5.4.0 20160609] setuptools 20.7.0 SQLite 3.11.0 Subversion 1.9.3 (r1718519) jQuery 1.12.4 jQuery UI 1.12.1 jQuery Timepicker 1.6.3 Installed Plugins Name Version Location TracArchiveViewer 0.3.dev0 /usr/local/lib/python2.7/dist-packages/TracArchiveViewer-0.3.dev0-py2.7.egg TracBookmark 1.0.2 /usr/local/lib/python2.7/dist-packages/TracBookmark-1.0.2-py2.7.egg TracWikiPrint 4.0.0.dev0 /usr/local/lib/python2.7/dist-packages
comment:5 follow-up: 7 Changed 2 years ago by
The issue occurs when an anonymous user clicks PDF Page download link. It doesn't when an authenticated user clicks the link.
-
tracpdf/wikiprint.py
252 252 :param pagename: name of the current wiki page 253 253 :return: dict with wkhtmltopdf global options 254 254 """ 255 for name in ('trac_auth', 'trac_session'): 256 if name in req.incookie: 257 cookie = [(name, req.incookie[name].value)] 258 break 259 else: 260 cookie = [] 255 261 options = { 256 262 'page-size': req.args.get('pagesize') or self.pagesize, 257 263 'encoding': "UTF-8", 258 264 'outline': None, 259 265 'title': req.args.get('pdftitle') or self.pdftitle or pagename, 260 'cookie': [ 261 ('trac_auth', req.incookie['trac_auth'].value), 262 ] 266 'cookie': cookie, 263 267 } 264 268 self._add_footer(options, pagename, req.args.get('footertext')) 265 269 return options
comment:7 follow-up: 8 Changed 13 months ago by
Replying to Jun Omae:
The issue occurs when an anonymous user clicks PDF Page download link. It doesn't when an authenticated user clicks the link.
For me it happens for an authenticated user. I am using http authorization. This is in the trac log:
2023-10-17 08:55:32,575 Trac[main] ERROR: [10.4.81.11] Internal Server Error: <RequestWithSession "GET '/wiki/WikiStart?format=pdfpage'">, referrer 'http://10.2.10.40/systems/wiki' Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/web/main.py", line 610, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/web/main.py", line 302, in dispatch raise e File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/web/main.py", line 248, in dispatch resp = chosen_handler.process_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/wiki/web_ui.py", line 184, in process_request Mimeview(self.env).send_converted(req, 'text/x-trac-wiki', File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/mimeview/api.py", line 1039, in send_converted content, output_type, ext = self.convert_content(req, in_type, content, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/mimeview/api.py", line 712, in convert_content output = conversion.converter.convert_content(req, mimetype, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/TracWikiPrint-4.0.0.dev0-py3.11.egg/tracpdf/wikiprint.py", line 218, in convert_content pdfoptions = self.prepare_pdf_options(req, pagename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/TracWikiPrint-4.0.0.dev0-py3.11.egg/tracpdf/wikiprint.py", line 261, in prepare_pdf_options ('trac_auth', req.incookie['trac_auth'].value), ~~~~~~~~~~~~^^^^^^^^^^^^^ KeyError: 'trac_auth'
comment:8 follow-up: 9 Changed 13 months ago by
Replying to anonymous:
For me it happens for an authenticated user. I am using http authorization. This is in the trac log:
... File "/usr/lib/python3.11/site-packages/TracWikiPrint-4.0.0.dev0-py3.11.egg/tracpdf/wikiprint.py", line 261, in prepare_pdf_options ('trac_auth', req.incookie['trac_auth'].value), ~~~~~~~~~~~~^^^^^^^^^^^^^ KeyError: 'trac_auth'
Try the following patch (untested):
-
tracpdf/wikiprint.py
23 23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 import base64 26 27 import re 27 28 from pdfkit import from_url 28 29 from trac.env import Component, implements … … 257 258 'encoding': "UTF-8", 258 259 'outline': None, 259 260 'title': req.args.get('pdftitle') or self.pdftitle or pagename, 260 'cookie': [261 ('trac_auth', req.incookie['trac_auth'].value),262 ]263 261 } 262 263 for name in ('trac_auth', 'trac_session'): 264 if name in req.incookie: 265 options['cookie'] = [(name, req.incookie[name].value)] 266 break 267 268 authorization = (req.get_header('Authorization') or '').split() 269 if len(authorization) == 2 and authorization[0].lower() == 'basic': 270 try: 271 creds = base64.b64decode(authorization[1]) 272 except: 273 pass 274 else: 275 creds = creds.split(b':', 1) 276 if len(creds) == 2: 277 options['username'] = to_unicode(creds[0]) 278 options['password'] = to_unicode(creds[1]) 279 264 280 self._add_footer(options, pagename, req.args.get('footertext')) 265 281 return options 266 282
comment:9 follow-up: 10 Changed 13 months ago by
Replying to Jun Omae:
Try the following patch (untested):
I have done that patch, and I now get this:
OSError: No wkhtmltopdf executable found: "b''" If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
I am installing via python3 setup.py install
in the trunk
directory. The install instructions are rather unclear on that point. If installing that way, what other things (and from where) need to be installed? In the source tree is xhtml2pdf
, not wkhtmltopdf
.
comment:10 Changed 13 months ago by
Replying to anonymous:
I have done that patch, and I now get this:
OSError: No wkhtmltopdf executable found: "b''" If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
I see that wkhtmltopdf
is a binary to install. I am sorting that out for my platform (openSUSE Tumbleweed Linux). Stay tuned.
comment:11 follow-up: 12 Changed 13 months ago by
After installing wkhtmltopdf
, I get this:
OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: AuthenticationRequiredError
I can run the program from the command line.
comment:12 follow-up: 13 Changed 13 months ago by
OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: AuthenticationRequiredError
- Dump
options
forpdfkit
(with DEBUG logging level)self._add_footer(options, pagename, req.args.get('footertext')) + self.log.debug('options: %r', options) return options
- Check
username
andpassword
is in theoptions
variable - Check whether it is able to generate pdf file from the URL by invoking manually
wkhtmltopdf
with theoptions
variable.
comment:13 follow-up: 19 Changed 13 months ago by
Replying to Jun Omae:
OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: AuthenticationRequiredError
- Dump
options
forpdfkit
(with DEBUG logging level)self._add_footer(options, pagename, req.args.get('footertext')) + self.log.debug('options: %r', options) return options
- Check
username
andpassword
is in theoptions
variable- Check whether it is able to generate pdf file from the URL by invoking manually
wkhtmltopdf
with theoptions
variable.
It prints this:
2023-10-20 10:38:52,194 Trac[wikiprint] DEBUG: options: {'page-size': 'A4', 'encoding': 'UTF-8', 'outline': None, 'title': 'WikiStart', 'footer-center': '[page] / [topage]', 'footer-line': None, 'footer-font-size': 10}
So username
and password
are not in the options.
I'm not familiar with wkhtmltopdf
. Exactly how would it be invoked with these options?
comment:14 follow-up: 15 Changed 13 months ago by
If I print authorization
, I get:
2023-10-20 11:21:00,288 Trac[wikiprint] DEBUG: authorization: []
This:
self.log.debug('header: %r', req.get_header('Authorization'))
prints:
2023-10-20 11:23:50,914 Trac[wikiprint] DEBUG: header: None
comment:15 follow-up: 16 Changed 13 months ago by
If I print
authorization
, I get:2023-10-20 11:21:00,288 Trac[wikiprint] DEBUG: authorization: []
If you're using mod_wsgi, try to configure WSGIPassAuthorization On. If not, please share configurations for web server and the authentications.
comment:16 Changed 13 months ago by
Replying to Jun Omae:
If I print
authorization
, I get:2023-10-20 11:21:00,288 Trac[wikiprint] DEBUG: authorization: []If you're using mod_wsgi, try to configure WSGIPassAuthorization On. If not, please share configurations for web server and the authentications.
One step further. I now get this when authentication:
2023-10-23 10:23:22,780 Trac[wikiprint] DEBUG: header: 'Basic cm9nZXI6dmlraW5nOQ==' 2023-10-23 10:23:22,780 Trac[wikiprint] DEBUG: authorization: ['Basic', 'cm9nZXI6dmlraW5nOQ=='] 2023-10-23 10:23:22,780 Trac[wikiprint] DEBUG: creds: b'login:secret'
The login
and secret
are the expected values. When I try to print a wiki page, I now get this:
2023-10-23 10:23:24,096 Trac[main] ERROR: [10.4.86.128] Internal Server Error: <RequestWithSession "GET '/wiki/WikiStart?format=pdfpage'">, referrer 'http://10.2.10.40/systems/wiki' Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/web/main.py", line 610, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/web/main.py", line 302, in dispatch raise e File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/web/main.py", line 248, in dispatch resp = chosen_handler.process_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/wiki/web_ui.py", line 184, in process_request Mimeview(self.env).send_converted(req, 'text/x-trac-wiki', File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/mimeview/api.py", line 1039, in send_converted content, output_type, ext = self.convert_content(req, in_type, content, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/Trac-1.5.4.dev0-py3.11.egg/trac/mimeview/api.py", line 712, in convert_content output = conversion.converter.convert_content(req, mimetype, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/TracWikiPrint-4.0.0.dev0-py3.11.egg/tracpdf/wikiprint.py", line 245, in convert_content pdf_page = from_url(page_lst, False, options=pdfoptions, cover=cover_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/pdfkit-1.0.0-py3.11.egg/pdfkit/api.py", line 27, in from_url return r.to_pdf(output_path) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/pdfkit-1.0.0-py3.11.egg/pdfkit/pdfkit.py", line 201, in to_pdf self.handle_error(exit_code, stderr) File "/usr/lib/python3.11/site-packages/pdfkit-1.0.0-py3.11.egg/pdfkit/pdfkit.py", line 155, in handle_error raise IOError('wkhtmltopdf reported an error:\n' + stderr) OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: UnknownContentError OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: UnknownContentError
comment:17 Changed 13 months ago by
(Sorry about the formatting in the previous comment. I cannot edit the previous comment to correct it...)
comment:18 Changed 13 months ago by
That is an issue of wkhtmltopdf. Please report to the wkhtmltopdf project. Also, try to run wkhtmltopdf command manually.
comment:19 Changed 13 months ago by
2023-10-20 10:38:52,194 Trac[wikiprint] DEBUG: options: {'page-size': 'A4', 'encoding': 'UTF-8', 'outline': None, 'title': 'WikiStart', 'footer-center': '[page] / [topage]', 'footer-line': None, 'footer-font-size': 10}I'm not familiar with
wkhtmltopdf
. Exactly how would it be invoked with these options?
Try to run the wkhtmltopdf command like this (after replacing with correct credentials and URL).
wkhtmltopdf \ --page-size A4 --encoding UTF-8 --outline --title WikiStart \ --footer-center '[page] / [topage]' --footer-line --footer-font-size 10 \ --username login --password secret \ http://your-hostname/path/to/wiki/WikiStart
comment:20 Changed 13 months ago by
I get this when running the command:
Loading pages (1/6) Error: Failed to load http://10.2.10.40/systems/chrome/wikiautocomplete/css/jquery.textcomplete.css, with network status code 299 and http status code 500 - Error downloading http://10.2.10.40/systems/chrome/wikiautocomplete/css/jquery.textcomplete.css - server replied: Internal Server Error Warning: Failed to load http://10.2.10.40/systems/chrome/wikiautocomplete/js/wikiautocomplete.js (ignore) Error: Failed to load http://10.2.10.40/systems/chrome/wikiautocomplete/js/jquery.textcomplete.min.js, with network status code 299 and http status code 500 - Error downloading http://10.2.10.40/systems/chrome/wikiautocomplete/js/jquery.textcomplete.min.js - server replied: Internal Server Error Counting pages (2/6) Resolving links (4/6) Loading headers and footers (5/6) Printing pages (6/6) Done Exit with code 1 due to network error: UnknownContentError
comment:21 follow-up: 22 Changed 13 months ago by
I should add that the generated PDF had the wiki page. So perhaps the error is not fatal? No idea.
comment:22 follow-up: 23 Changed 13 months ago by
I should add that the generated PDF had the wiki page. So perhaps the error is not fatal? No idea.
Hm? You got error messages about resources of wikiautocompleteplugin.
Error: Failed to load http://10.2.10.40/systems/chrome/wikiautocomplete/css/jquery.textcomplete.css, with network status code 299 and http status code 500 - Error downloading http://10.2.10.40/systems/chrome/wikiautocomplete/css/jquery.textcomplete.css - server replied: Internal Server Error Warning: Failed to load http://10.2.10.40/systems/chrome/wikiautocomplete/js/wikiautocomplete.js (ignore) Error: Failed to load http://10.2.10.40/systems/chrome/wikiautocomplete/js/jquery.textcomplete.min.js, with network status code 299 and http status code 500 - Error downloading http://10.2.10.40/systems/chrome/wikiautocomplete/js/jquery.textcomplete.min.js - server replied: Internal Server Error
Check access log and error log of your web server and try to correct configurations of your web server.
comment:23 Changed 13 months ago by
Replying to Jun Omae:
I should add that the generated PDF had the wiki page. So perhaps the error is not fatal? No idea.
Hm? You got error messages about resources of wikiautocompleteplugin. Check access log and error log of your web server and try to correct configurations of your web server.
The autocomplete package is installed. I know this indicates that the problem is not in the WikiPrint plugin. But it is the only component that is complaining about it. I see these components in
systems/.egg-cache/TracWikiAutoComplete-1.4-py3.11.egg-tmp/wikiautocomplete/htdocs
Which contains:
.: total 8 drwxr-xr-x 2 wwwrun www 4096 Oct 17 08:46 css drwxr-xr-x 2 wwwrun www 4096 Oct 17 08:46 js ./css: total 4 -rwxr-xr-x 1 wwwrun www 598 Feb 26 2017 jquery.textcomplete.css ./js: total 28 -rwxr-xr-x 1 wwwrun www 20246 Nov 16 2016 jquery.textcomplete.min.js -rwxr-xr-x 1 wwwrun www 5163 Feb 13 2021 wikiautocomplete.js
Is this where it would be searched for? I just did a straight forward install of this plugin with python3 ./setup.py install
.
comment:24 Changed 13 months ago by
I see that the tracautocomplete
error is caused by a wikiprint
error reported in #14163. When I do that change to wikiprint
, the wikiautocomplete
complaint goes away.
The error that remains is:
OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: UnknownContentError
I will next pursue that.
comment:25 Changed 13 months ago by
If I run this command:
wkhtmltopdf --page-size A4 --encoding UTF-8 --outline --title WikiStart --footer-center '[page] / [topage]' --footer-line --footer-font-size 10 --username me --password secret http://10.2.10.40/systems/wiki/GPS gps.pdf
I get the expected PDF. But it does not work in Trac on the same page.
When processing, the command prints:
Loading pages (1/6) Counting pages (2/6) Resolving links (4/6) Loading headers and footers (5/6) Printing pages (6/6) Done
No errors or anything.
comment:26 Changed 13 months ago by
Retry after applying the following patch:
-
tracpdf/wikiprint.py
241 242 page_lst.append(req.abs_href('wikiprint', pagename, version=version, 242 243 stylepage=stylepage, filterwiki=filterwiki)) 243 244 # Now call pdfkit without a file name so it returns the PDF. 244 pdf_page = from_url(page_lst, False, options=pdfoptions, cover=cover_url )245 pdf_page = from_url(page_lst, False, options=pdfoptions, cover=cover_url, verbose=True) 245 246 246 247 return pdf_page, 'application/pdf' 247 248
According to source code of pdfkit, wkhtmltopdf sometimes exits with non-zero and pdfkit ignores non-zero exit code when second last line of the stderr is Done
.
# Sometimes wkhtmltopdf will exit with non-zero # even if it finishes generation. # If will display 'Done' in the second last line if len(stderr_lines) > 1 and stderr.splitlines()[-2].strip() == 'Done': return
at https://github.com/JazzCore/python-pdfkit/blob/1.0.0/pdfkit/pdfkit.py#L142-L146
However, the stderr should be empty because --quiet
option is used by default since pdfkit 1.0.0.
if not self.verbose: self.options.update({'--quiet': ''})
at https://github.com/JazzCore/python-pdfkit/blob/1.0.0/pdfkit/pdfkit.py#L93-L94
If the issue is not fixed by the patch, please report to pdfkit and/or wkhtmlpdf project. That is not an issue of the plugin.
comment:27 Changed 13 months ago by
The verbose=True
seems to have fixed the problem. I now get a PDF page. Thanks for your help!
See attachement.