OLD | NEW |
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
3 """The image export front-end.""" | 2 """The image export CLI tool.""" |
4 | 3 |
5 import argparse | 4 import argparse |
6 import logging | 5 import logging |
7 import os | 6 import os |
8 import sys | |
9 import textwrap | 7 import textwrap |
10 | 8 |
11 from plaso.cli import storage_media_tool | 9 from plaso.cli import storage_media_tool |
12 from plaso.frontend import image_export | 10 from plaso.frontend import image_export |
13 from plaso.lib import errors | 11 from plaso.lib import errors |
14 | 12 |
15 | 13 |
16 class ImageExportTool(storage_media_tool.StorageMediaTool): | 14 class ImageExportTool(storage_media_tool.StorageMediaTool): |
17 """Class that implements the image export CLI tool. | 15 """Class that implements the image export CLI tool. |
18 | 16 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 self.ScanSource() | 270 self.ScanSource() |
273 | 271 |
274 self._output_writer.Write(u'Export started.\n') | 272 self._output_writer.Write(u'Export started.\n') |
275 | 273 |
276 self._front_end.ProcessSources( | 274 self._front_end.ProcessSources( |
277 self._source_path_specs, self._destination_path, self._output_writer, | 275 self._source_path_specs, self._destination_path, self._output_writer, |
278 filter_file=self._filter_file, skip_duplicates=self._skip_duplicates) | 276 filter_file=self._filter_file, skip_duplicates=self._skip_duplicates) |
279 | 277 |
280 self._output_writer.Write(u'Export completed.\n') | 278 self._output_writer.Write(u'Export completed.\n') |
281 self._output_writer.Write(u'\n') | 279 self._output_writer.Write(u'\n') |
282 | |
283 | |
284 def Main(): | |
285 """The main function.""" | |
286 tool = ImageExportTool() | |
287 | |
288 if not tool.ParseArguments(): | |
289 return False | |
290 | |
291 if tool.list_signature_identifiers: | |
292 tool.ListSignatureIdentifiers() | |
293 return True | |
294 | |
295 if not tool.has_filters: | |
296 logging.warning(u'No filter defined exporting all files.') | |
297 | |
298 # TODO: print more status information like PrintOptions. | |
299 tool.PrintFilterCollection() | |
300 | |
301 try: | |
302 tool.ProcessSources() | |
303 | |
304 except (KeyboardInterrupt, errors.UserAbort): | |
305 logging.warning(u'Aborted by user.') | |
306 return False | |
307 | |
308 except errors.BadConfigOption as exception: | |
309 logging.warning(exception) | |
310 return False | |
311 | |
312 except errors.SourceScannerError as exception: | |
313 logging.warning(( | |
314 u'Unable to scan for a supported filesystem with error: {0:s}\n' | |
315 u'Most likely the image format is not supported by the ' | |
316 u'tool.').format(exception)) | |
317 return False | |
318 | |
319 return True | |
320 | |
321 | |
322 if __name__ == '__main__': | |
323 if not Main(): | |
324 sys.exit(1) | |
325 else: | |
326 sys.exit(0) | |
OLD | NEW |