#!/usr/bin/env python
# coding=utf-8
"""
Copyright 2013 LinkedIn Corp. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import logging
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'src')))
from naarad import Naarad
import naarad.utils as Utils
import naarad.naarad_constants as CONSTANTS


def main():
  args = Utils.get_argument_parser().parse_args()
  Utils.validate_arguments(args)
  logger = logging.getLogger('naarad')
  Utils.init_logging(logger, CONSTANTS.NAARAD_LOG, args.log)
  logger.info('Reports will be in %s', args.output_dir)
  if args.diff:
    status = Naarad().diff_reports_by_location(args.diff[0], args.diff[1], args.output_dir, config=args.config, args=args)
  else:
    status = Naarad().analyze(args.input_dir, args.output_dir, config=args.config, skip_plots=args.no_plots, args=args)
  logger.info('Reports will be in %s', args.output_dir)
  if args.exit_code:
    sys.exit(status)

if __name__ == '__main__':
  main()
