try:
proc = Popen([unoconv, '--show'], stderr=PIPE)
output = proc.stderr.read()
- except OSError, e:
+ except OSError:
_log.warn(_('unoconv failing to run, check log file'))
return False
- if 'ERROR' in output:
+ if b'ERROR' in output:
return False
return True
_log.debug('pdfinfo could not read the pdf file.')
raise BadMediaFail()
+ lines = [l.decode('utf-8', 'replace') for l in lines]
info_dict = dict([[part.strip() for part in l.strip().split(':', 1)]
for l in lines if ':' in l])
"""
Store the pdf. If the file is not a pdf, make it a pdf
"""
- tmp_pdf = self.process_filename
+ tmp_pdf = os.path.splitext(self.process_filename)[0] + '.pdf'
unoconv = where('unoconv')
+ args = [unoconv, '-v', '-f', 'pdf', self.process_filename]
+ _log.debug('calling %s' % repr(args))
Popen(executable=unoconv,
- args=[unoconv, '-v', '-f', 'pdf', self.process_filename]).wait()
+ args=args).wait()
if not os.path.exists(tmp_pdf):
_log.debug('unoconv failed to convert file to pdf')
class PdfProcessingManager(ProcessingManager):
def __init__(self):
- super(self.__class__, self).__init__()
+ super(PdfProcessingManager, self).__init__()
self.add_processor(InitialProcessor)
self.add_processor(Resizer)