diff options
Diffstat (limited to 'MAT/mat.py')
| -rw-r--r-- | MAT/mat.py | 20 |
1 files changed, 12 insertions, 8 deletions
| @@ -13,6 +13,8 @@ import xml.sax | |||
| 13 | import hachoir_core.cmd_line | 13 | import hachoir_core.cmd_line |
| 14 | import hachoir_parser | 14 | import hachoir_parser |
| 15 | 15 | ||
| 16 | import MAT.exceptions | ||
| 17 | |||
| 16 | __version__ = '0.4' | 18 | __version__ = '0.4' |
| 17 | __author__ = 'jvoisin' | 19 | __author__ = 'jvoisin' |
| 18 | 20 | ||
| @@ -107,18 +109,20 @@ def secure_remove(filename): | |||
| 107 | ''' | 109 | ''' |
| 108 | securely remove the file | 110 | securely remove the file |
| 109 | ''' | 111 | ''' |
| 110 | removed = False | ||
| 111 | try: | 112 | try: |
| 112 | subprocess.call(['shred', '--remove', filename]) | 113 | if subprocess.call(['shred', '--remove', filename]) == 0: |
| 113 | removed = True | 114 | return True |
| 115 | else: | ||
| 116 | raise OSError | ||
| 114 | except OSError: | 117 | except OSError: |
| 115 | logging.error('Unable to securely remove %s' % filename) | 118 | logging.error('Unable to securely remove %s' % filename) |
| 116 | 119 | ||
| 117 | if not removed: | 120 | try: |
| 118 | try: | 121 | os.remove(filename) |
| 119 | os.remove(filename) | 122 | return True |
| 120 | except OSError: | 123 | except OSError: |
| 121 | logging.error('Unable to remove %s' % filename) | 124 | logging.error('Unable to remove %s' % filename) |
| 125 | raise MAT.exceptions.UnableToRemoveFile | ||
| 122 | 126 | ||
| 123 | 127 | ||
| 124 | def create_class_file(name, backup, **kwargs): | 128 | def create_class_file(name, backup, **kwargs): |
