def shell_command(command, wait=True):
  '''
  Call a shell command, translating common exceptions. Command is a list of
  items to pass to the shell, e.g. ['ls', '-l'].
  '''
  try:
    log.debug("shell command: %s", " ".join(command))
    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
    if wait:
      p.wait()
    else:
      return p
  except subprocess.CalledProcessError, e:
    raise ShellError("shell command '%s' returned status %s" % (" ".join(command), e.returncode))
  except OSError, e:
    raise ShellError("shell command '%s' failed: %s" % (" ".join(command), e))
dataset/ETHPy150Open bloomreach/zinc/zinc.py/shell_command/original