#!/usr/bin/env python
# Programmer: Chris Bunch (chris@appscale.com)


# General-purpose Python library imports
import sys
import traceback


# AppScale library imports
from appscale.tools import version_helper
from appscale.tools.appscale_tools import AppScaleTools
from appscale.tools.local_state import LocalState
from appscale.tools.parse_args import ParseArgs


version_helper.ensure_valid_python_is_used()


if __name__ == "__main__":
  options = ParseArgs(sys.argv[1:], "appscale-gather-logs").args
  try:
    AppScaleTools.gather_logs(options)
    sys.exit(0)
  except Exception, e:
    LocalState.generate_crash_log(e, traceback.format_exc())
    sys.exit(1)
