From 1e5ca09893284ae2f807ea4a00fbc79fba33e360 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 12 Apr 2013 22:09:39 +0200 Subject: Strippers are now using logging instead of print --- MAT/mat.py | 3 ++- MAT/strippers.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'MAT') 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 import hachoir_core.cmd_line import hachoir_parser -import strippers __version__ = '0.3.4' __author__ = 'jvoisin' @@ -30,6 +29,8 @@ LOGGING_LEVEL = logging.DEBUG logging.basicConfig(filename=fname, level=LOGGING_LEVEL) +import strippers # this is loaded here because we need LOGGING_LEVEL + def get_logo(): if os.path.isfile('./data/mat.png'): 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 import gi import office import archive +import mat import misc import subprocess +import logging STRIPPERS = { 'application/x-tar': archive.TarStripper, @@ -20,25 +22,26 @@ STRIPPERS = { 'application/officeopenxml': office.OpenXmlStripper, } +logging.basicConfig(level=mat.LOGGING_LEVEL) # PDF support pdfSupport = True try: from gi.repository import Poppler except ImportError: - print('Unable to import Poppler') + logging.info('Unable to import Poppler: no PDF support') pdfSupport = False try: import cairo except ImportError: - print('Unable to import python-cairo: no PDF support') + logging.info('Unable to import python-cairo: no PDF support') pdfSupport = False try: import pdfrw except ImportError: - print('Unable to import python-pdfrw: no PDf support') + logging.info('Unable to import python-pdfrw: no PDf support') pdfSupport = False if pdfSupport: @@ -53,7 +56,7 @@ try: STRIPPERS['audio/vorbis'] = audio.OggStripper STRIPPERS['audio/mpeg'] = audio.MpegAudioStripper except ImportError: - print('Unable to import python-mutagen: limited audio format support') + logging.info('Unable to import python-mutagen: limited audio format support') # exiftool try: @@ -62,6 +65,6 @@ try: STRIPPERS['image/jpeg'] = exiftool.JpegStripper STRIPPERS['image/png'] = exiftool.PngStripper except OSError: # if exiftool is not installed, use hachoir instead - print('Unable to find exiftool: limited images support') + logging.info('Unable to find exiftool: limited images support') STRIPPERS['image/jpeg'] = images.JpegStripper STRIPPERS['image/png'] = images.PngStripper -- cgit v1.3