X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=mediagoblin%2Fmedia_types%2Fpdf%2Fprocessing.py;h=ac4bab6d55a51a39594d9fabd9d6a472c9ccc8ff;hb=e2b44bd7a7478792be47c98086f5c91d0da283e2;hp=4dd894d849c85121ec1ab11a46def6e6f070e0c8;hpb=690f50de1c0f56dd49558c38de8aac213a658672;p=mediagoblin.git diff --git a/mediagoblin/media_types/pdf/processing.py b/mediagoblin/media_types/pdf/processing.py index 4dd894d8..ac4bab6d 100644 --- a/mediagoblin/media_types/pdf/processing.py +++ b/mediagoblin/media_types/pdf/processing.py @@ -138,10 +138,10 @@ def is_unoconv_working(): 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 @@ -207,6 +207,7 @@ def pdf_info(original): _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]) @@ -316,11 +317,13 @@ class CommonPdfProcessor(MediaProcessor): """ 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') @@ -464,6 +467,6 @@ class Resizer(CommonPdfProcessor): class PdfProcessingManager(ProcessingManager): def __init__(self): - super(self.__class__, self).__init__() + super(PdfProcessingManager, self).__init__() self.add_processor(InitialProcessor) self.add_processor(Resizer)