From c9562087fdabdafec11a673ca86e7d43e4071d76 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 11 May 2012 14:53:05 +0200 Subject: Informatives messages for missings libraries --- lib/strippers.py | 30 ++++++++++++++++++++++++------ test/test.py | 3 ++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/strippers.py b/lib/strippers.py index dfdf1ea..61030a7 100644 --- a/lib/strippers.py +++ b/lib/strippers.py @@ -20,24 +20,42 @@ STRIPPERS = { 'application/officeopenxml': office.OpenXmlStripper, } -try: # PDF support + +# PDF support +pdfSupport = True +try: import poppler +except ImportError: + print('Unable to import python-poppler: not PDF support') + pdfSupport = False + +try: import cairo +except ImportError: + print('Unable to import python-cairo: no PDF support') + pdfSupport = False + +try: import pdfrw +except ImportError: + print('Unable to import python-pdfrw: no PDf support') + pdfSupport = False + +if pdfSupport: STRIPPERS['application/x-pdf'] = office.PdfStripper STRIPPERS['application/pdf'] = office.PdfStripper -except ImportError: - print('Unable to import python-poppler and/or python-cairo \ -and/or pdfrw: no PDF support') -try: # mutangen-python : audio format support + +# audio format support with mutagen-python +try: import mutagen STRIPPERS['audio/x-flac'] = audio.FlacStripper STRIPPERS['audio/vorbis'] = audio.OggStripper except ImportError: print('Unable to import python-mutagen: limited audio format support') -try: # check if exiftool is installed on the system +# exiftool +try: subprocess.Popen('exiftool', stdout=open('/dev/null')) import exiftool STRIPPERS['image/jpeg'] = exiftool.JpegStripper diff --git a/test/test.py b/test/test.py index 630c157..f09e1c5 100644 --- a/test/test.py +++ b/test/test.py @@ -28,6 +28,7 @@ FILE_LIST = zip(clean, dirty) try: # PDF render processing import poppler import cairo + import pdfrw except: FILE_LIST.remove(('clean é.pdf', 'dirty é.pdf')) @@ -37,7 +38,7 @@ except: pass # since wr don't have any ogg for now #FILE_LIST.remove(('clean.ogg', 'dirty.ogg')) -try: # file format managed by exiftool +try: # file format exclusively managed by exiftool subprocess.Popen('exiftool', stdout=open('/dev/null')) except: pass # None for now -- cgit v1.3