Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/pdfkit/configuration.py : 27%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2import subprocess
3import sys
6class Configuration(object):
7 def __init__(self, wkhtmltopdf='', meta_tag_prefix='pdfkit-'):
8 self.meta_tag_prefix = meta_tag_prefix
10 self.wkhtmltopdf = wkhtmltopdf
12 if not self.wkhtmltopdf:
13 if sys.platform == 'win32':
14 self.wkhtmltopdf = subprocess.Popen(
15 ['where', 'wkhtmltopdf'], stdout=subprocess.PIPE).communicate()[0].strip()
16 else:
17 self.wkhtmltopdf = subprocess.Popen(
18 ['which', 'wkhtmltopdf'], stdout=subprocess.PIPE).communicate()[0].strip()
20 try:
21 with open(self.wkhtmltopdf) as f:
22 pass
23 except IOError:
24 raise IOError('No wkhtmltopdf executable found: "%s"\n'
25 'If this file exists please check that this process can '
26 'read it. Otherwise please install wkhtmltopdf - '
27 'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)