diff options
| author | jvoisin | 2011-07-18 14:19:02 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-18 14:19:02 +0200 |
| commit | 5e4f031ade2de68bbbc467afd208ef1f56ef973b (patch) | |
| tree | 7ca84412a81ac08a74688f612ed7aea9ac131843 | |
| parent | fe68c6541536c6b65b7193ef07bec0ac39feeaed (diff) | |
Proper logging system
Diffstat (limited to '')
| -rw-r--r-- | lib/mat.py | 11 |
1 files changed, 7 insertions, 4 deletions
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | import os | 7 | import os |
| 8 | import subprocess | 8 | import subprocess |
| 9 | import logging | ||
| 9 | 10 | ||
| 10 | import hachoir_core.cmd_line | 11 | import hachoir_core.cmd_line |
| 11 | import hachoir_parser | 12 | import hachoir_parser |
| @@ -19,6 +20,8 @@ import archive | |||
| 19 | __version__ = "0.1" | 20 | __version__ = "0.1" |
| 20 | __author__ = "jvoisin" | 21 | __author__ = "jvoisin" |
| 21 | 22 | ||
| 23 | logging.basicConfig(level = logging.DEBUG) | ||
| 24 | |||
| 22 | strippers = { | 25 | strippers = { |
| 23 | hachoir_parser.image.JpegFile: images.JpegStripper, | 26 | hachoir_parser.image.JpegFile: images.JpegStripper, |
| 24 | hachoir_parser.image.PngFile: images.PngStripper, | 27 | hachoir_parser.image.PngFile: images.PngStripper, |
| @@ -36,7 +39,7 @@ def secure_remove(filename): | |||
| 36 | try: | 39 | try: |
| 37 | subprocess.call('shred --remove %s' % filename, shell=True) | 40 | subprocess.call('shred --remove %s' % filename, shell=True) |
| 38 | except: | 41 | except: |
| 39 | print('Unable to remove %s' % filename) | 42 | logging.error('Unable to remove %s' % filename) |
| 40 | 43 | ||
| 41 | 44 | ||
| 42 | def is_secure(filename): | 45 | def is_secure(filename): |
| @@ -45,7 +48,7 @@ def is_secure(filename): | |||
| 45 | ''' | 48 | ''' |
| 46 | 49 | ||
| 47 | if not(os.path.isfile(filename)): #check if the file exist | 50 | if not(os.path.isfile(filename)): #check if the file exist |
| 48 | print("Error: %s is not a valid file" % filename) | 51 | logging.error("Error: %s is not a valid file" % filename) |
| 49 | return | 52 | return |
| 50 | 53 | ||
| 51 | def create_class_file(name, backup): | 54 | def create_class_file(name, backup): |
| @@ -60,7 +63,7 @@ def create_class_file(name, backup): | |||
| 60 | filename = hachoir_core.cmd_line.unicodeFilename(name) | 63 | filename = hachoir_core.cmd_line.unicodeFilename(name) |
| 61 | parser = hachoir_parser.createParser(filename) | 64 | parser = hachoir_parser.createParser(filename) |
| 62 | if not parser: | 65 | if not parser: |
| 63 | print("[+] Unable to parse %s" % filename) | 66 | logging.error("Unable to parse %s" % filename) |
| 64 | return | 67 | return |
| 65 | 68 | ||
| 66 | editor = hachoir_editor.createEditor(parser) | 69 | editor = hachoir_editor.createEditor(parser) |
| @@ -73,7 +76,7 @@ def create_class_file(name, backup): | |||
| 73 | stripper_class = strippers[editor.input.__class__] | 76 | stripper_class = strippers[editor.input.__class__] |
| 74 | except KeyError: | 77 | except KeyError: |
| 75 | #Place for another lib than hachoir | 78 | #Place for another lib than hachoir |
| 76 | print("[+] Don't have stripper for file type %s" % editor.description) | 79 | logging.error("Don't have stripper for file type %s" % editor.description) |
| 77 | return | 80 | return |
| 78 | if editor.input.__class__ == hachoir_parser.misc.PDFDocument: | 81 | if editor.input.__class__ == hachoir_parser.misc.PDFDocument: |
| 79 | return stripper_class(filename, realname, backup) | 82 | return stripper_class(filename, realname, backup) |
