_logger = logging.getLogger(__name__)
def _get_wkhtmltopdf_bin():
- return find_in_path('wkhtmltopdf')
+ wkhtmltopdf_bin = find_in_path('wkhtmltopdf')
+ if wkhtmltopdf_bin is None:
+ raise IOError
+ return wkhtmltopdf_bin
#--------------------------------------------------------------------------
process = subprocess.Popen(
[_get_wkhtmltopdf_bin(), '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
-except (OSError, IOError, ValueError):
+except (OSError, IOError):
_logger.info('You need Wkhtmltopdf to print a pdf version of the reports.')
else:
_logger.info('Will use the Wkhtmltopdf binary at %s' % _get_wkhtmltopdf_bin())
# We include the *Base ones just in case, currently they seem to be subclasses of the _* ones.
SKIPPED_ELEMENT_TYPES = (etree._Comment, etree._ProcessingInstruction, etree.CommentBase, etree.PIBase)
-DEFAULT_PATH = os.environ.get('PATH', os.defpath).split(os.pathsep)
-if config.get('bin_path'):
- DEFAULT_PATH.append(config['bin_path'])
-
def find_in_path(name):
+ path = os.environ.get('PATH', os.defpath).split(os.pathsep)
+ if config.get('bin_path') and config['bin_path'] != 'None':
+ path.append(config['bin_path'])
try:
- return which(name, path=os.pathsep.join(DEFAULT_PATH))
+ return which(name, path=os.pathsep.join(path))
except IOError:
return None