# Path: auto_forensicate/errors.py
# class BadConfigOption(Exception):
# class ForensicateError(Exception):
# class RecipeException(Exception):
# class RetryableError(ForensicateError):
# 
# Path: auto_forensicate/recipes/base.py
# class BaseArtifact(object):
# class StringArtifact(BaseArtifact):
# class FileArtifact(BaseArtifact):
# class ProcessOutputArtifact(BaseArtifact):
# class BaseRecipe(object):
#   def __init__(self, name):
#   def _GetStream(self):
#   def CloseStream(self):
#   def OpenStream(self):
#   def size(self):
#   def readable_size(self):
#   def __init__(self, path, string_content):
#   def _GetStream(self):
#   def CloseStream(self):
#   def __init__(self, path):
#   def _GetStream(self):
#   def __init__(self, command, path, ignore_failure=False):
#   def _RunCommand(self):
#   def _GetStream(self):
#   def __init__(self, name, options=None):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/ux/cli.py
# def AskText(message, mandatory=False):
# def AskDiskList(disk_list):
# def Confirm(text, default='N'):
# 
# Path: auto_forensicate/ux/gui.py
# def AskText(message, mandatory=False):
# def AskDiskList(disk_list):
# def Confirm(text):


import os
import subprocess
from auto_forensicate import errors
from auto_forensicate.recipes import base
from auto_forensicate.ux import cli
from auto_forensicate.ux import gui
      IOError: if CloseStream() is called before GetStream().
    """
    if not self._copyprocess:
      raise IOError('Illegal call to CloseStream() before GetStream()')

    # If there is anything still to read from the subprocess then CloseStream
    # has been called early, terminate the child process to avoid deadlock.
    character = self._copyprocess.stdout.read(1)
    if character:
      self._copyprocess.terminate()
      raise subprocess.CalledProcessError(
          0, self._copy_command[0],
          'CloseStream() called but stdout still had data')

    self._copyprocess.wait()
    code = self._copyprocess.returncode
    error = self._copyprocess.stderr.read()
    if code < 0:
      raise subprocess.CalledProcessError(code, self._copy_command[0], error)
    return error

  def _GenerateCopyCommand(self):
    """Builds the command to run on the directory.

    Returns:
      list: the argument list for the dd command
    """
    if self._method == 'tar':
      return self._GenerateTarCopyCommand()
    else:

# Path: auto_forensicate/errors.py
# class BadConfigOption(Exception):
# class ForensicateError(Exception):
# class RecipeException(Exception):
# class RetryableError(ForensicateError):
# 
# Path: auto_forensicate/recipes/base.py
# class BaseArtifact(object):
# class StringArtifact(BaseArtifact):
# class FileArtifact(BaseArtifact):
# class ProcessOutputArtifact(BaseArtifact):
# class BaseRecipe(object):
#   def __init__(self, name):
#   def _GetStream(self):
#   def CloseStream(self):
#   def OpenStream(self):
#   def size(self):
#   def readable_size(self):
#   def __init__(self, path, string_content):
#   def _GetStream(self):
#   def CloseStream(self):
#   def __init__(self, path):
#   def _GetStream(self):
#   def __init__(self, command, path, ignore_failure=False):
#   def _RunCommand(self):
#   def _GetStream(self):
#   def __init__(self, name, options=None):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/ux/cli.py
# def AskText(message, mandatory=False):
# def AskDiskList(disk_list):
# def Confirm(text, default='N'):
# 
# Path: auto_forensicate/ux/gui.py
# def AskText(message, mandatory=False):
# def AskDiskList(disk_list):
# def Confirm(text):


# Path: auto_forensicate/recipes/directory.py
import os
import subprocess
from auto_forensicate import errors
from auto_forensicate.recipes import base
from auto_forensicate.ux import cli
from auto_forensicate.ux import gui

      IOError: if CloseStream() is called before GetStream().
    """
    if not self._copyprocess:
      raise IOError('Illegal call to CloseStream() before GetStream()')

    # If there is anything still to read from the subprocess then CloseStream
    # has been called early, terminate the child process to avoid deadlock.
    character = self._copyprocess.stdout.read(1)
    if character:
      self._copyprocess.terminate()
      raise subprocess.CalledProcessError(
          0, self._copy_command[0],
          'CloseStream() called but stdout still had data')

    self._copyprocess.wait()
    code = self._copyprocess.returncode
    error = self._copyprocess.stderr.read()
    if code < 0:
      raise subprocess.CalledProcessError(code, self._copy_command[0], error)
    return error

  def _GenerateCopyCommand(self):
    """Builds the command to run on the directory.

    Returns:
      list: the argument list for the dd command
    """
    if self._method == 'tar':
      return self._GenerateTarCopyCommand()
    else:

      raise errors.RecipeException('Unsupported method '+self._method)