summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2013-04-12 22:09:39 +0200
committerjvoisin2013-04-12 22:09:39 +0200
commit1e5ca09893284ae2f807ea4a00fbc79fba33e360 (patch)
tree669633ab2f997b228aa42ceabb6758a0fccebb31
parent552ec3a580f55732f79f18f771f06c88279e6771 (diff)
Strippers are now using logging instead of print
-rw-r--r--MAT/mat.py3
-rw-r--r--MAT/strippers.py13
2 files changed, 10 insertions, 6 deletions
diff --git a/MAT/mat.py b/MAT/mat.py
index 7a8d73e..3a0938a 100644
--- a/MAT/mat.py
+++ b/MAT/mat.py
@@ -13,7 +13,6 @@ import xml.sax
13import hachoir_core.cmd_line 13import hachoir_core.cmd_line
14import hachoir_parser 14import hachoir_parser
15 15
16import strippers
17 16
18__version__ = '0.3.4' 17__version__ = '0.3.4'
19__author__ = 'jvoisin' 18__author__ = 'jvoisin'
@@ -30,6 +29,8 @@ LOGGING_LEVEL = logging.DEBUG
30 29
31logging.basicConfig(filename=fname, level=LOGGING_LEVEL) 30logging.basicConfig(filename=fname, level=LOGGING_LEVEL)
32 31
32import strippers # this is loaded here because we need LOGGING_LEVEL
33
33def get_logo(): 34def get_logo():
34 if os.path.isfile('./data/mat.png'): 35 if os.path.isfile('./data/mat.png'):
35 return './data/mat.png' 36 return './data/mat.png'
diff --git a/MAT/strippers.py b/MAT/strippers.py
index 4279755..5eaf233 100644
--- a/MAT/strippers.py
+++ b/MAT/strippers.py
@@ -7,8 +7,10 @@ import audio
7import gi 7import gi
8import office 8import office
9import archive 9import archive
10import mat
10import misc 11import misc
11import subprocess 12import subprocess
13import logging
12 14
13STRIPPERS = { 15STRIPPERS = {
14 'application/x-tar': archive.TarStripper, 16 'application/x-tar': archive.TarStripper,
@@ -20,25 +22,26 @@ STRIPPERS = {
20 'application/officeopenxml': office.OpenXmlStripper, 22 'application/officeopenxml': office.OpenXmlStripper,
21} 23}
22 24
25logging.basicConfig(level=mat.LOGGING_LEVEL)
23 26
24# PDF support 27# PDF support
25pdfSupport = True 28pdfSupport = True
26try: 29try:
27 from gi.repository import Poppler 30 from gi.repository import Poppler
28except ImportError: 31except ImportError:
29 print('Unable to import Poppler') 32 logging.info('Unable to import Poppler: no PDF support')
30 pdfSupport = False 33 pdfSupport = False
31 34
32try: 35try:
33 import cairo 36 import cairo
34except ImportError: 37except ImportError:
35 print('Unable to import python-cairo: no PDF support') 38 logging.info('Unable to import python-cairo: no PDF support')
36 pdfSupport = False 39 pdfSupport = False
37 40
38try: 41try:
39 import pdfrw 42 import pdfrw
40except ImportError: 43except ImportError:
41 print('Unable to import python-pdfrw: no PDf support') 44 logging.info('Unable to import python-pdfrw: no PDf support')
42 pdfSupport = False 45 pdfSupport = False
43 46
44if pdfSupport: 47if pdfSupport:
@@ -53,7 +56,7 @@ try:
53 STRIPPERS['audio/vorbis'] = audio.OggStripper 56 STRIPPERS['audio/vorbis'] = audio.OggStripper
54 STRIPPERS['audio/mpeg'] = audio.MpegAudioStripper 57 STRIPPERS['audio/mpeg'] = audio.MpegAudioStripper
55except ImportError: 58except ImportError:
56 print('Unable to import python-mutagen: limited audio format support') 59 logging.info('Unable to import python-mutagen: limited audio format support')
57 60
58# exiftool 61# exiftool
59try: 62try:
@@ -62,6 +65,6 @@ try:
62 STRIPPERS['image/jpeg'] = exiftool.JpegStripper 65 STRIPPERS['image/jpeg'] = exiftool.JpegStripper
63 STRIPPERS['image/png'] = exiftool.PngStripper 66 STRIPPERS['image/png'] = exiftool.PngStripper
64except OSError: # if exiftool is not installed, use hachoir instead 67except OSError: # if exiftool is not installed, use hachoir instead
65 print('Unable to find exiftool: limited images support') 68 logging.info('Unable to find exiftool: limited images support')
66 STRIPPERS['image/jpeg'] = images.JpegStripper 69 STRIPPERS['image/jpeg'] = images.JpegStripper
67 STRIPPERS['image/png'] = images.PngStripper 70 STRIPPERS['image/png'] = images.PngStripper