# Path: auto_forensicate/errors.py
# class BadConfigOption(Exception):
# class ForensicateError(Exception):
# class RecipeException(Exception):
# class RetryableError(ForensicateError):
# 
# Path: auto_forensicate/hostinfo.py
# def ReadDMI(name):
# def GetChassisSerial():
# def GetMachineUUID():
# def GetRandomUUID():
# def GetIdentifier():
# def GetUdevadmInfo(device_name):
# def GetTime():
# def Which(cmd):
# 
# Path: auto_forensicate/uploader.py
# class BaseUploader(object):
# class LocalCopier(BaseUploader):
# class GCSUploader(BaseUploader):
#   def __init__(self, stamp_manager, stamp=None):
#   def _UploadStamp(self):
#   def _MakeRemotePath(self, destination):
#   def _UploadStream(self, stream, remote_path, update_callback=None):
#   def UploadArtifact(self, artifact, update_callback=None):
#   def __init__(self, destination_dir, stamp_manager, stamp=None):
#   def _UploadStream(self, stream, remote_path, update_callback=None):
#   def _MakeRemotePath(self, destination):
#   def __init__(self, gs_url, gs_keyfile, client_id, stamp_manager, stamp=None):
#   def _InitBoto(self):
#   def _SplitGCSUrl(self):
#   def _MakeRemotePath(self, destination):
#   def _UploadStream(self, stream, remote_path, update_callback=None):
# 
# Path: auto_forensicate/recipes/directory.py
# def FullPathToName(path):
#   def __init__(self, path, method='tar', compress=False):
#   def _GetSize(self):
#   def _GetStream(self):
#   def CloseStream(self):
#   def _GenerateCopyCommand(self):
#   def _GenerateTarCopyCommand(self):
#   def __init__(self, path, method='tar', compress=False):
#   def __init__(self, path, method='tar', compress=False):
#   def GetArtifacts(self):
# class DirectoryArtifact(base.BaseArtifact):
# class LinuxDirectoryArtifact(DirectoryArtifact):
# class MacDirectoryArtifact(DirectoryArtifact):
# class DirectoryRecipe(base.BaseRecipe):
#   _SUPPORTED_METHODS = ['tar']
#   _TAR_COMMAND = [
#       'tar', '-c', '-p', '--xattrs', '--acls', '--format=posix', '-f', '-']
# 
# Path: auto_forensicate/recipes/disk.py
# class DiskArtifact(base.BaseArtifact):
# class MacDiskArtifact(DiskArtifact):
# class LinuxDiskArtifact(DiskArtifact):
# class DiskRecipe(base.BaseRecipe):
#   _DD_BINARY = 'dcfldd'
#   _DD_OPTIONS = ['hash=md5,sha1', 'bs=2M', 'conv=noerror', 'hashwindow=128M']
#   def __init__(self, path, size, use_dcfldd=True):
#   def _GenerateDDCommand(self):
#   def _GetStream(self):
#   def CloseStream(self):
#   def GetDescription(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def _IsUsb(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def GetDescription(self):
#   def _GetUdevadmProperty(self, prop):
#   def ProbablyADisk(self):
#   def _IsFloppy(self):
#   def _IsUsb(self):
#   def __init__(self, name, options=None):
#   def _GetLsblkDict(self):
#   def _ListAllDisksMac(self):
#   def _ListAllDisksLinux(self):
#   def _ListDisks(self, all_devices=False, names=None):
#   def _GetListDisksArtifact(self):
#   def _GetDiskInfoArtifact(self, disk):
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/recipes/firmware.py
# class ChipsecRecipe(base.BaseRecipe):
#   _CHIPSEC_CMD = [
#       'chipsec_util', '-l', '/dev/stderr', 'spi', 'dump', '/dev/stdout']
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/recipes/sysinfo.py
# class SysinfoRecipe(base.BaseRecipe):
#   _SYSTEM_PROFILER_CMD = [
#       '/usr/sbin/system_profiler', 'SPHardwareDataType', 'SPSoftwareDataType']
#   _NETWORKSETUP_CMD = [
#       '/usr/sbin/networksetup', '-listallhardwareports']
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/stamp/manager.py
# class BaseStampManager(object):
#   def BasePathElements(self, stamp):
#   def GetStamp(self):


import argparse
import json
import logging
import sys
import time
import gcs_oauth2_boto_plugin  # pylint: disable=unused-import
from google.cloud import logging as cloud_logging
from google.cloud.logging_v2 import logger as cloud_logger
from google.cloud.logging_v2 import handlers as cloud_handlers
from google.oauth2 import service_account
from progress.bar import IncrementalBar
from progress.spinner import Spinner
from auto_forensicate import errors
from auto_forensicate import hostinfo
from auto_forensicate import uploader
from auto_forensicate.recipes import directory
from auto_forensicate.recipes import disk
from auto_forensicate.recipes import firmware
from auto_forensicate.recipes import sysinfo
from auto_forensicate.stamp import manager
    argument.

    Args:
      options (argparse.Namespace): the parsed command-line arguments.
    Returns:
      Uploader: an uploader object.
    Raises:
      errors.BadConfigOption: if the options are invalid.
    """

    stamp_manager = manager.BaseStampManager()

    if options.destination.startswith('gs://'):
      if not self._gcs_settings:
        raise errors.BadConfigOption(
            'Please provide a valid GCS json file. '
            'See --gs_keyfile option'
        )

      client_id = self._gcs_settings.get('client_id', None)

      if not client_id:
        raise errors.BadConfigOption(
            'The provided GCS json file lacks a "client_id" key.'
        )

      return uploader.GCSUploader(
          options.destination, options.gs_keyfile, client_id, stamp_manager)

    if options.destination.startswith('/'):

# Path: auto_forensicate/errors.py
# class BadConfigOption(Exception):
# class ForensicateError(Exception):
# class RecipeException(Exception):
# class RetryableError(ForensicateError):
# 
# Path: auto_forensicate/hostinfo.py
# def ReadDMI(name):
# def GetChassisSerial():
# def GetMachineUUID():
# def GetRandomUUID():
# def GetIdentifier():
# def GetUdevadmInfo(device_name):
# def GetTime():
# def Which(cmd):
# 
# Path: auto_forensicate/uploader.py
# class BaseUploader(object):
# class LocalCopier(BaseUploader):
# class GCSUploader(BaseUploader):
#   def __init__(self, stamp_manager, stamp=None):
#   def _UploadStamp(self):
#   def _MakeRemotePath(self, destination):
#   def _UploadStream(self, stream, remote_path, update_callback=None):
#   def UploadArtifact(self, artifact, update_callback=None):
#   def __init__(self, destination_dir, stamp_manager, stamp=None):
#   def _UploadStream(self, stream, remote_path, update_callback=None):
#   def _MakeRemotePath(self, destination):
#   def __init__(self, gs_url, gs_keyfile, client_id, stamp_manager, stamp=None):
#   def _InitBoto(self):
#   def _SplitGCSUrl(self):
#   def _MakeRemotePath(self, destination):
#   def _UploadStream(self, stream, remote_path, update_callback=None):
# 
# Path: auto_forensicate/recipes/directory.py
# def FullPathToName(path):
#   def __init__(self, path, method='tar', compress=False):
#   def _GetSize(self):
#   def _GetStream(self):
#   def CloseStream(self):
#   def _GenerateCopyCommand(self):
#   def _GenerateTarCopyCommand(self):
#   def __init__(self, path, method='tar', compress=False):
#   def __init__(self, path, method='tar', compress=False):
#   def GetArtifacts(self):
# class DirectoryArtifact(base.BaseArtifact):
# class LinuxDirectoryArtifact(DirectoryArtifact):
# class MacDirectoryArtifact(DirectoryArtifact):
# class DirectoryRecipe(base.BaseRecipe):
#   _SUPPORTED_METHODS = ['tar']
#   _TAR_COMMAND = [
#       'tar', '-c', '-p', '--xattrs', '--acls', '--format=posix', '-f', '-']
# 
# Path: auto_forensicate/recipes/disk.py
# class DiskArtifact(base.BaseArtifact):
# class MacDiskArtifact(DiskArtifact):
# class LinuxDiskArtifact(DiskArtifact):
# class DiskRecipe(base.BaseRecipe):
#   _DD_BINARY = 'dcfldd'
#   _DD_OPTIONS = ['hash=md5,sha1', 'bs=2M', 'conv=noerror', 'hashwindow=128M']
#   def __init__(self, path, size, use_dcfldd=True):
#   def _GenerateDDCommand(self):
#   def _GetStream(self):
#   def CloseStream(self):
#   def GetDescription(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def _IsUsb(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def GetDescription(self):
#   def _GetUdevadmProperty(self, prop):
#   def ProbablyADisk(self):
#   def _IsFloppy(self):
#   def _IsUsb(self):
#   def __init__(self, name, options=None):
#   def _GetLsblkDict(self):
#   def _ListAllDisksMac(self):
#   def _ListAllDisksLinux(self):
#   def _ListDisks(self, all_devices=False, names=None):
#   def _GetListDisksArtifact(self):
#   def _GetDiskInfoArtifact(self, disk):
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/recipes/firmware.py
# class ChipsecRecipe(base.BaseRecipe):
#   _CHIPSEC_CMD = [
#       'chipsec_util', '-l', '/dev/stderr', 'spi', 'dump', '/dev/stdout']
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/recipes/sysinfo.py
# class SysinfoRecipe(base.BaseRecipe):
#   _SYSTEM_PROFILER_CMD = [
#       '/usr/sbin/system_profiler', 'SPHardwareDataType', 'SPSoftwareDataType']
#   _NETWORKSETUP_CMD = [
#       '/usr/sbin/networksetup', '-listallhardwareports']
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/stamp/manager.py
# class BaseStampManager(object):
#   def BasePathElements(self, stamp):
#   def GetStamp(self):


# Path: auto_forensicate/auto_acquire.py
import argparse
import json
import logging
import sys
import time
import gcs_oauth2_boto_plugin  # pylint: disable=unused-import
from google.cloud import logging as cloud_logging
from google.cloud.logging_v2 import logger as cloud_logger
from google.cloud.logging_v2 import handlers as cloud_handlers
from google.oauth2 import service_account
from progress.bar import IncrementalBar
from progress.spinner import Spinner
from auto_forensicate import errors
from auto_forensicate import hostinfo
from auto_forensicate import uploader
from auto_forensicate.recipes import directory
from auto_forensicate.recipes import disk
from auto_forensicate.recipes import firmware
from auto_forensicate.recipes import sysinfo
from auto_forensicate.stamp import manager

    argument.

    Args:
      options (argparse.Namespace): the parsed command-line arguments.
    Returns:
      Uploader: an uploader object.
    Raises:
      errors.BadConfigOption: if the options are invalid.
    """

    stamp_manager = manager.BaseStampManager()

    if options.destination.startswith('gs://'):
      if not self._gcs_settings:
        raise errors.BadConfigOption(
            'Please provide a valid GCS json file. '
            'See --gs_keyfile option'
        )

      client_id = self._gcs_settings.get('client_id', None)

      if not client_id:
        raise errors.BadConfigOption(
            'The provided GCS json file lacks a "client_id" key.'
        )

      return uploader.GCSUploader(
          options.destination, options.gs_keyfile, client_id, stamp_manager)

    if options.destination.startswith('/'):

      return uploader.LocalCopier(options.destination, stamp_manager)