# Path: gslib/exception.py
# NO_URLS_MATCHED_PREFIX = 'No URLs matched'
# NO_URLS_MATCHED_GENERIC = (NO_URLS_MATCHED_PREFIX +
#                            '. Do the files you\'re operating on exist?')
# NO_URLS_MATCHED_TARGET = NO_URLS_MATCHED_PREFIX + ': %s'
# class AbortException(StandardError):
# class CommandException(StandardError):
# class ControlCException(Exception):
# class GcloudStorageTranslationError(Exception):
# class HashMismatchException(Exception):
# class IamChOnResourceWithConditionsException(Exception):
# class InvalidUrlError(Exception):
# class ExternalBinaryError(Exception):
#   def __init__(self, reason):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, reason, informational=False):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):


import subprocess
from gslib import exception
from __future__ import division
from __future__ import unicode_literals




def ExecuteExternalCommand(command_and_flags):
  """Runs external terminal command.

  Args:
    command_and_flags (List[str]): Ordered command and flag strings.

  Returns:
    (stdout (str|None), stderr (str|None)) from running command.

  Raises:
    OSError for any issues running the command.
  """
  command_process = subprocess.Popen(command_and_flags,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
  command_stdout, command_stderr = command_process.communicate()

  # Python 3 outputs bytes from communicate() by default.
  if command_stdout is not None and not isinstance(command_stdout, str):
    command_stdout = command_stdout.decode()
  if command_stderr is not None and not isinstance(command_stderr, str):
    command_stderr = command_stderr.decode()

  if command_process.returncode != 0:

# Path: gslib/exception.py
# NO_URLS_MATCHED_PREFIX = 'No URLs matched'
# NO_URLS_MATCHED_GENERIC = (NO_URLS_MATCHED_PREFIX +
#                            '. Do the files you\'re operating on exist?')
# NO_URLS_MATCHED_TARGET = NO_URLS_MATCHED_PREFIX + ': %s'
# class AbortException(StandardError):
# class CommandException(StandardError):
# class ControlCException(Exception):
# class GcloudStorageTranslationError(Exception):
# class HashMismatchException(Exception):
# class IamChOnResourceWithConditionsException(Exception):
# class InvalidUrlError(Exception):
# class ExternalBinaryError(Exception):
#   def __init__(self, reason):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, reason, informational=False):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):


# Path: gslib/utils/execution_util.py
import subprocess
from gslib import exception

from __future__ import division
from __future__ import unicode_literals




def ExecuteExternalCommand(command_and_flags):
  """Runs external terminal command.

  Args:
    command_and_flags (List[str]): Ordered command and flag strings.

  Returns:
    (stdout (str|None), stderr (str|None)) from running command.

  Raises:
    OSError for any issues running the command.
  """
  command_process = subprocess.Popen(command_and_flags,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
  command_stdout, command_stderr = command_process.communicate()

  # Python 3 outputs bytes from communicate() by default.
  if command_stdout is not None and not isinstance(command_stdout, str):
    command_stdout = command_stdout.decode()
  if command_stderr is not None and not isinstance(command_stderr, str):
    command_stderr = command_stderr.decode()

  if command_process.returncode != 0:

    raise exception.ExternalBinaryError(command_stderr)