Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The storage interface classes.""" | 2 """The storage interface classes.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import abc | 6 import abc |
7 import os | 7 import os |
8 import shutil | 8 import shutil |
9 import tempfile | 9 import tempfile |
10 | 10 |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 | 943 |
944 Args: | 944 Args: |
945 time_range (Optional[TimeRange]): time range used to filter events | 945 time_range (Optional[TimeRange]): time range used to filter events |
946 that fall in a specific period. | 946 that fall in a specific period. |
947 | 947 |
948 Yields: | 948 Yields: |
949 EventObject: event. | 949 EventObject: event. |
950 """ | 950 """ |
951 | 951 |
952 def FinalizeProcessedTaskStorage(self, unused_task): | 952 def FinalizeProcessedTaskStorage(self, unused_task): |
953 """Finalized a proccessed a task storage. | 953 """Finalizes a proccessed a task storage. |
onager
2018/04/07 13:15:54
Finalizes
Joachim Metz
2018/04/07 16:49:28
Done.
| |
954 | 954 |
955 Args: | 955 Args: |
956 task (Task): task. | 956 task (Task): task. |
957 | 957 |
958 Raises: | 958 Raises: |
959 NotImplementedError: since there is no implementation. | 959 NotImplementedError: since there is no implementation. |
960 """ | 960 """ |
961 raise NotImplementedError() | 961 raise NotImplementedError() |
962 | 962 |
963 @abc.abstractmethod | 963 @abc.abstractmethod |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1371 if not self._storage_file: | 1371 if not self._storage_file: |
1372 raise IOError('Unable to read from closed storage writer.') | 1372 raise IOError('Unable to read from closed storage writer.') |
1373 | 1373 |
1374 event_source = self._storage_file.GetEventSourceByIndex( | 1374 event_source = self._storage_file.GetEventSourceByIndex( |
1375 self._written_event_source_index) | 1375 self._written_event_source_index) |
1376 if event_source: | 1376 if event_source: |
1377 self._written_event_source_index += 1 | 1377 self._written_event_source_index += 1 |
1378 return event_source | 1378 return event_source |
1379 | 1379 |
1380 def GetProcessedTaskIdentifiers(self): | 1380 def GetProcessedTaskIdentifiers(self): |
1381 """Retrieves task identifiers which are processed. | 1381 """Identifers for tasks which have been processed. |
onager
2018/04/07 13:15:54
"Identifers for tasks which have been processed"
Joachim Metz
2018/04/07 16:49:28
Done.
| |
1382 | 1382 |
1383 Returns: | 1383 Returns: |
1384 list[str]: task identifiers that are processed. | 1384 list[str]: task identifiers that are processed. |
1385 | 1385 |
1386 Raises: | 1386 Raises: |
1387 IOError: if the storage type is not supported or | 1387 IOError: if the storage type is not supported or |
1388 if the temporary path for the task storage does not exist. | 1388 if the temporary path for the task storage does not exist. |
1389 """ | 1389 """ |
1390 if self._storage_type != definitions.STORAGE_TYPE_SESSION: | 1390 if self._storage_type != definitions.STORAGE_TYPE_SESSION: |
1391 raise IOError('Unsupported storage type.') | 1391 raise IOError('Unsupported storage type.') |
1392 | 1392 |
1393 if not self._processed_task_storage_path: | 1393 if not self._processed_task_storage_path: |
1394 raise IOError('Missing processed task storage path.') | 1394 raise IOError('Missing processed task storage path.') |
1395 | 1395 |
1396 return [ | 1396 return [ |
1397 path.replace('.plaso', '') | 1397 path.replace('.plaso', '') |
onager
2018/04/07 14:34:06
This is going to cause issues if there's ever a no
Joachim Metz
2018/04/07 16:49:28
this was introduced in https://github.com/log2time
| |
1398 for path in os.listdir(self._processed_task_storage_path)] | 1398 for path in os.listdir(self._processed_task_storage_path)] |
1399 | 1399 |
1400 def GetSortedEvents(self, time_range=None): | 1400 def GetSortedEvents(self, time_range=None): |
1401 """Retrieves the events in increasing chronological order. | 1401 """Retrieves the events in increasing chronological order. |
1402 | 1402 |
1403 This includes all events written to the storage including those pending | 1403 This includes all events written to the storage including those pending |
1404 being flushed (written) to the storage. | 1404 being flushed (written) to the storage. |
1405 | 1405 |
1406 Args: | 1406 Args: |
1407 time_range (Optional[TimeRange]): time range used to filter events | 1407 time_range (Optional[TimeRange]): time range used to filter events |
1408 that fall in a specific period. | 1408 that fall in a specific period. |
1409 | 1409 |
1410 Returns: | 1410 Returns: |
1411 generator(EventObject): event generator. | 1411 generator(EventObject): event generator. |
1412 | 1412 |
1413 Raises: | 1413 Raises: |
1414 IOError: when the storage writer is closed. | 1414 IOError: when the storage writer is closed. |
1415 """ | 1415 """ |
1416 if not self._storage_file: | 1416 if not self._storage_file: |
1417 raise IOError('Unable to read from closed storage writer.') | 1417 raise IOError('Unable to read from closed storage writer.') |
1418 | 1418 |
1419 return self._storage_file.GetSortedEvents(time_range=time_range) | 1419 return self._storage_file.GetSortedEvents(time_range=time_range) |
1420 | 1420 |
1421 def FinalizeProcessedTaskStorage(self, task): | 1421 def FinalizeProcessedTaskStorage(self, task): |
1422 """Finalized a proccessed a task storage. | 1422 """Finalized a proccessed a task storage. |
onager
2018/04/07 13:15:54
Finalizes a processed task storage
Joachim Metz
2018/04/07 16:49:28
Done.
| |
1423 | 1423 |
1424 Moves the task storage file from its temporary directory to the processed | 1424 Moves the task storage file from its temporary directory to the processed |
1425 directory. | 1425 directory. |
1426 | 1426 |
1427 Args: | 1427 Args: |
1428 task (Task): task. | 1428 task (Task): task. |
1429 | 1429 |
1430 Raises: | 1430 Raises: |
1431 IOError: if the storage type is not supported or | 1431 IOError: if the storage type is not supported or |
1432 if the storage file cannot be renamed. | 1432 if the storage file cannot be renamed. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1699 IOError: if the storage type is not supported or | 1699 IOError: if the storage type is not supported or |
1700 when the storage writer is closed. | 1700 when the storage writer is closed. |
1701 """ | 1701 """ |
1702 self._RaiseIfNotWritable() | 1702 self._RaiseIfNotWritable() |
1703 | 1703 |
1704 if self._storage_type != definitions.STORAGE_TYPE_TASK: | 1704 if self._storage_type != definitions.STORAGE_TYPE_TASK: |
1705 raise IOError('Unsupported storage type.') | 1705 raise IOError('Unsupported storage type.') |
1706 | 1706 |
1707 task_start = self._task.CreateTaskStart() | 1707 task_start = self._task.CreateTaskStart() |
1708 self._storage_file.WriteTaskStart(task_start) | 1708 self._storage_file.WriteTaskStart(task_start) |
LEFT | RIGHT |