Example #1
0
def main():

    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.FATAL)

    sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
    sys.stderr = codecs.getwriter('utf-8')(sys.stderr)

    parser = OptionParser()

    parser.add_option("",
                      "--target_dir",
                      dest="target_dir",
                      help="HTML report target directory. The script will place the cnaf ggus report in the given directory.")


    (options, args) = parser.parse_args()

    print "cnaf-mon v. %s. " % __version__

    if options.target_dir is None:
        print >> sys.stderr, "Please set the --target_dir option!"
        sys.exit(2)

    check_ticket_status(report_dir=options.target_dir)
Example #2
0
def main():

    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.FATAL)

    sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
    sys.stderr = codecs.getwriter('utf-8')(sys.stderr)

    parser = OptionParser()
    parser.add_option("-t",
                      "--twiki-format",
                      dest="twiki",
                      help="Prepares output conforming to the EMI weekly ticket status report",
                      action="store_true",
                      default=False)

    parser.add_option("-p",
                      "--period",
                      dest="period",
                      help="Period for which the stats should be computed. It's a string in the format dd/mm/yyyy-dd/mm/yyyy Example: 01/01/2011-31/01/2011.")

    parser.add_option("-s",
                      "--su",
                      dest="su",
                      help="List of SUs for which the stats should be computed.")

    parser.add_option("",
                      "--start",
                      dest="start",
                      help="Record start.")

    parser.add_option("",
                      "--limit",
                      dest="limit",
                      help="Record limit.")

    parser.add_option("",
                      "--target_dir",
                      dest="target_dir",
                      help="HTML report target directory. The script will place the cnaf ggus report in the given directory.")

    parser.add_option("",
                      "--report_url",
                      dest="report_url",
                      help="URL where generated report can be accessed.")
    parser.add_option("",
                      "--recipients",
                      dest="recipients",
                      help="List of comma separated email addresses that will be notified of report generation.")

    parser.add_option("",
                      "--skip_notification",
                      dest="skip_notification",
                      action="store_true",
                      help="Generates the report but doesn't send out the notification",
                      default=False)


    (options, args) = parser.parse_args()

    print "emi-ggus-mon v. %s. " % __version__

    if len(args) == 0:
        print
        print "Producing EMI support status report, please be patient..."
        print
        print_assigned_ticket_status_report(options.twiki)
    else:
        cmd = args[0]
        if cmd == "eta":
            print_eta_status_report()

        elif cmd == "on-hold":

            print_on_hold_report()

        elif cmd == 'su':
            print_su_report()

        elif cmd == 'sla':
            start_date = SLA_START_DATE
            end_date = datetime.now()

            if options.period:
                (start_date,end_date) = parse_period(options.period)

            print_sla_stats(start_date, end_date)

        elif cmd == 'sla-su':
            start_date = SLA_START_DATE
            end_date = datetime.now()

            if options.period:
                (start_date,end_date) = parse_period(options.period)

            sus = None
            if options.su:
                sus = split(options.su,',')

            print_sla_report(start_date, end_date, sus)

        elif cmd == 'submitted-tickets':
            start_date = SLA_START_DATE
            end_date = datetime.now()

            if options.period:
                (start_date,end_date) = parse_period(options.period)

            print_submitted_tickets_report(start_date,end_date)

        elif cmd == 'ksa1.1':
            start_date = SLA_START_DATE
            end_date = datetime.now()

            if options.period:
                (start_date,end_date) = parse_period(options.period)

            print_ksa_1_1(start_date,end_date)

        elif cmd == 'ksa1.2':
            start_date = SLA_START_DATE
            end_date = datetime.now()
            if options.period:
                (start_date,end_date) = parse_period(options.period)

            print_ksa_1_2(start_date,end_date)

        elif cmd == "ticket-history":
            print_ticket_history(args[1:])

        elif cmd == "all-tickets":
            start = 0
            limit = -1

            if options.limit:
                limit = options.limit
                if options.start:
                    start = options.start

            print_all_tickets_report(start,limit)

        elif cmd == 'cnaf':
            if options.target_dir is None:
                print >> sys.stderr, "Please set the --target_dir option!"
                sys.exit(2)

            check_ticket_status(report_dir=options.target_dir,
                                report_url=options.report_url,
                                recipients=options.recipients,
                                skip_notification=options.skip_notification)
        else:
            print >>sys.stderr, "Unknown command ", cmd
            sys.exit(1)