# Path: auto_forensicate/hostinfo.py
# def Which(cmd):
#   """Searches for a binary in the current PATH environment variable.
# 
#   Args:
#     cmd(str): the binary to search for.
#   Returns:
#     str: the first found path to a binary with the same name, or None.
#   """
#   path_list = os.environ.get('PATH', os.defpath).split(os.pathsep)
#   for directory in path_list:
#     name = os.path.join(directory, cmd)
#     if os.path.isdir(name):
#       continue
#     if os.path.exists(name) and os.access(name, os.F_OK | os.X_OK):
#       return name
#   return None


import subprocess
from auto_forensicate.hostinfo import Which



def GetYesNo(text):
  """Ask user a Yes/No question.

  Args:
    text(str): The message to display.
  Returns:
    bool: the user's answer.
  """

  zenity_binary = Which('zenity')

  process = subprocess.Popen(
      [zenity_binary, '--question', '--text="{0:s}"'.format(text)],
      stdin=subprocess.PIPE, stdout=subprocess.PIPE)

  return process.wait() == 0


def GetText(text):
  """Ask user for a string.

  Args:
    text(str): The message to display.
  Returns:
    str: the user input.
  """


# Path: auto_forensicate/hostinfo.py
# def Which(cmd):
#   """Searches for a binary in the current PATH environment variable.
# 
#   Args:
#     cmd(str): the binary to search for.
#   Returns:
#     str: the first found path to a binary with the same name, or None.
#   """
#   path_list = os.environ.get('PATH', os.defpath).split(os.pathsep)
#   for directory in path_list:
#     name = os.path.join(directory, cmd)
#     if os.path.isdir(name):
#       continue
#     if os.path.exists(name) and os.access(name, os.F_OK | os.X_OK):
#       return name
#   return None


# Path: auto_forensicate/ux/zenity.py
import subprocess
from auto_forensicate.hostinfo import Which




def GetYesNo(text):
  """Ask user a Yes/No question.

  Args:
    text(str): The message to display.
  Returns:
    bool: the user's answer.
  """

  zenity_binary = Which('zenity')

  process = subprocess.Popen(
      [zenity_binary, '--question', '--text="{0:s}"'.format(text)],
      stdin=subprocess.PIPE, stdout=subprocess.PIPE)

  return process.wait() == 0


def GetText(text):
  """Ask user for a string.

  Args:
    text(str): The message to display.
  Returns:
    str: the user input.
  """


  zenity_binary = Which('zenity')