Skip to content

Commit

Permalink
Code review: 267200043: Moved lib.storage to storage.zip_file log2tim…
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Dec 31, 2015
1 parent 413a60c commit 8417ac8
Show file tree
Hide file tree
Showing 24 changed files with 503 additions and 464 deletions.
2 changes: 1 addition & 1 deletion config/dpkg/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ python-plaso (1.3.1-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline <[email protected]> Mon, 12 Oct 2015 08:05:59 +0200
-- Log2Timeline <[email protected]> Tue, 13 Oct 2015 19:55:40 +0200
8 changes: 0 additions & 8 deletions docs/plaso.lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ plaso.lib.specification module
:undoc-members:
:show-inheritance:

plaso.lib.storage module
------------------------

.. automodule:: plaso.lib.storage
:members:
:undoc-members:
:show-inheritance:

plaso.lib.timelib module
------------------------

Expand Down
8 changes: 8 additions & 0 deletions docs/plaso.storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ plaso.storage.writer module
:undoc-members:
:show-inheritance:

plaso.storage.zip_file module
-----------------------------

.. automodule:: plaso.storage.zip_file
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------
Expand Down
2 changes: 1 addition & 1 deletion plaso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__version__ = '1.3.1'

VERSION_DEV = True
VERSION_DATE = '20151012'
VERSION_DATE = '20151013'


def GetVersion():
Expand Down
30 changes: 30 additions & 0 deletions plaso/cli/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,36 @@ def AddTimezoneOption(self, argument_group):
u'determined automatically where possible. Use "-z list" to '
u'see a list of available timezones.'))

def GetCommandLineArguments(self):
"""Retrieves the command line arguments.
Returns:
A string containing the command line arguments.
"""
command_line_arguments = sys.argv
if isinstance(command_line_arguments, py2to3.BYTES_TYPE):
encoding = sys.stdin.encoding

# Note that sys.stdin.encoding can be None.
if not encoding:
encoding = self.preferred_encoding

try:
command_line_arguments = [
argument.decode(encoding) for argument in command_line_arguments]

except UnicodeDecodeError:
logging.error(
u'Unable to properly read command line input due to encoding '
u'error. Replacing non Basic Latin (C0) characters with "?" or '
u'"\\ufffd".')

command_line_arguments = [
argument.decode(encoding, errors=u'replace')
for argument in command_line_arguments]

return u' '.join(command_line_arguments)

def ListTimeZones(self):
"""Lists the timezones."""
max_length = 0
Expand Down
15 changes: 3 additions & 12 deletions plaso/frontend/analysis_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from plaso.formatters import mediator as formatters_mediator
from plaso.frontend import frontend
from plaso.lib import storage
from plaso.storage import zip_file as storage_zip_file


class AnalysisFrontend(frontend.Frontend):
Expand All @@ -13,7 +13,6 @@ def __init__(self):
"""Initializes the front-end object."""
super(AnalysisFrontend, self).__init__()
self._data_location = None
self._storage_file = None

def GetFormatterMediator(self):
"""Retrieves the formatter mediator.
Expand All @@ -30,12 +29,12 @@ def OpenStorage(self, storage_file_path, read_only=True):
Args:
storage_file_path: the path of the storage file.
read_only: optional boolean value to indicate the storage file should
be opened in read-only mode. The default is True.
be opened in read-only mode.
Returns:
The storage file object (instance of StorageFile).
"""
return storage.StorageFile(storage_file_path, read_only=read_only)
return storage_zip_file.StorageFile(storage_file_path, read_only=read_only)

def SetDataLocation(self, data_location):
"""Set the data location.
Expand All @@ -45,11 +44,3 @@ def SetDataLocation(self, data_location):
from.
"""
self._data_location = data_location

def SetStorageFile(self, storage_file):
"""Set the storage file.
Args:
storage_file: The path to the storage file being parsed.
"""
self._storage_file = storage_file
4 changes: 2 additions & 2 deletions plaso/frontend/extraction_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
from plaso.lib import definitions
from plaso.lib import errors
from plaso.lib import event
from plaso.lib import storage
from plaso.lib import timelib
from plaso.multi_processing import multi_process
from plaso.hashers import manager as hashers_manager
from plaso.parsers import manager as parsers_manager
from plaso.storage import writer as storage_writer
from plaso.storage import zip_file as storage_zip_file

import pytz

Expand Down Expand Up @@ -166,7 +166,7 @@ def _PreprocessSource(self, source_path_specs, source_type):
if self._use_old_preprocess and os.path.isfile(self._storage_file_path):
# Check if the storage file contains a preprocessing object.
try:
with storage.StorageFile(
with storage_zip_file.StorageFile(
self._storage_file_path, read_only=True) as storage_file:

storage_information = storage_file.GetStorageInformation()
Expand Down
2 changes: 1 addition & 1 deletion plaso/frontend/log2timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _GetOutputModulesInformation(self):
A list of tuples of output module names and descriptions.
"""
output_modules_information = []
for name, description in sorted(output_manager.OutputManager.GetOutputs()):
for name, description in output_manager.OutputManager.GetOutputClasses():
output_modules_information.append((name, description))

return output_modules_information
Expand Down
Loading

0 comments on commit 8417ac8

Please sign in to comment.