diff options
| author | jvoisin | 2012-05-11 14:53:05 +0200 |
|---|---|---|
| committer | jvoisin | 2012-05-11 14:53:05 +0200 |
| commit | c9562087fdabdafec11a673ca86e7d43e4071d76 (patch) | |
| tree | 7a4e61fbc5696867b115e029285bf6260f8c109c | |
| parent | 836bd5d42e4ec4797c3a505aa0b3c5af2decdf97 (diff) | |
Informatives messages for missings libraries
| -rw-r--r-- | lib/strippers.py | 30 | ||||
| -rw-r--r-- | 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 = { | |||
| 20 | 'application/officeopenxml': office.OpenXmlStripper, | 20 | 'application/officeopenxml': office.OpenXmlStripper, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | try: # PDF support | 23 | |
| 24 | # PDF support | ||
| 25 | pdfSupport = True | ||
| 26 | try: | ||
| 24 | import poppler | 27 | import poppler |
| 28 | except ImportError: | ||
| 29 | print('Unable to import python-poppler: not PDF support') | ||
| 30 | pdfSupport = False | ||
| 31 | |||
| 32 | try: | ||
| 25 | import cairo | 33 | import cairo |
| 34 | except ImportError: | ||
| 35 | print('Unable to import python-cairo: no PDF support') | ||
| 36 | pdfSupport = False | ||
| 37 | |||
| 38 | try: | ||
| 26 | import pdfrw | 39 | import pdfrw |
| 40 | except ImportError: | ||
| 41 | print('Unable to import python-pdfrw: no PDf support') | ||
| 42 | pdfSupport = False | ||
| 43 | |||
| 44 | if pdfSupport: | ||
| 27 | STRIPPERS['application/x-pdf'] = office.PdfStripper | 45 | STRIPPERS['application/x-pdf'] = office.PdfStripper |
| 28 | STRIPPERS['application/pdf'] = office.PdfStripper | 46 | STRIPPERS['application/pdf'] = office.PdfStripper |
| 29 | except ImportError: | ||
| 30 | print('Unable to import python-poppler and/or python-cairo \ | ||
| 31 | and/or pdfrw: no PDF support') | ||
| 32 | 47 | ||
| 33 | try: # mutangen-python : audio format support | 48 | |
| 49 | # audio format support with mutagen-python | ||
| 50 | try: | ||
| 34 | import mutagen | 51 | import mutagen |
| 35 | STRIPPERS['audio/x-flac'] = audio.FlacStripper | 52 | STRIPPERS['audio/x-flac'] = audio.FlacStripper |
| 36 | STRIPPERS['audio/vorbis'] = audio.OggStripper | 53 | STRIPPERS['audio/vorbis'] = audio.OggStripper |
| 37 | except ImportError: | 54 | except ImportError: |
| 38 | print('Unable to import python-mutagen: limited audio format support') | 55 | print('Unable to import python-mutagen: limited audio format support') |
| 39 | 56 | ||
| 40 | try: # check if exiftool is installed on the system | 57 | # exiftool |
| 58 | try: | ||
| 41 | subprocess.Popen('exiftool', stdout=open('/dev/null')) | 59 | subprocess.Popen('exiftool', stdout=open('/dev/null')) |
| 42 | import exiftool | 60 | import exiftool |
| 43 | STRIPPERS['image/jpeg'] = exiftool.JpegStripper | 61 | 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) | |||
| 28 | try: # PDF render processing | 28 | try: # PDF render processing |
| 29 | import poppler | 29 | import poppler |
| 30 | import cairo | 30 | import cairo |
| 31 | import pdfrw | ||
| 31 | except: | 32 | except: |
| 32 | FILE_LIST.remove(('clean é.pdf', 'dirty é.pdf')) | 33 | FILE_LIST.remove(('clean é.pdf', 'dirty é.pdf')) |
| 33 | 34 | ||
| @@ -37,7 +38,7 @@ except: | |||
| 37 | pass # since wr don't have any ogg for now | 38 | pass # since wr don't have any ogg for now |
| 38 | #FILE_LIST.remove(('clean.ogg', 'dirty.ogg')) | 39 | #FILE_LIST.remove(('clean.ogg', 'dirty.ogg')) |
| 39 | 40 | ||
| 40 | try: # file format managed by exiftool | 41 | try: # file format exclusively managed by exiftool |
| 41 | subprocess.Popen('exiftool', stdout=open('/dev/null')) | 42 | subprocess.Popen('exiftool', stdout=open('/dev/null')) |
| 42 | except: | 43 | except: |
| 43 | pass # None for now | 44 | pass # None for now |
