def format_ticket_html(t):

    template_str = """
        <tr>
        <td>${su}</td>
        <td><a href="https://ggus.eu/ws/ticket_info.php?ticket=${id}">${id}</a></td>
        <td>${status}</td>
        <td class="prio_${prio_class}">${prio}</td>
        <td><h5>${desc}</h5></td>
        <td><span class=\"badge\">${age}</span></td>
        </tr>"""

    ggus_t = get_ggus_ticket(ticket_id(t))
    assigned_time = ggus_t.assigned_time()
    age = (datetime.now() - assigned_time).days


    template = Template(template_str)
    ticket_str = template.substitute({"id":ticket_id(t),
                         "desc": ticket_short_description(t),
                         "su": ticket_su(t),
                         "prio_class" : ticket_priority(t).replace(' ','_'),
                         "prio": ticket_priority(t),
                         "age": age,
                         "related": None,
                         "status": ticket_status(t)
                         })

    return ticket_str
def format_ticket(t):

    ggus_t = get_ggus_ticket(ticket_id(t))
    assigned_time = ggus_t.assigned_time()
    age = (datetime.now() - assigned_time).days

    warning = ""

    # if ticket_status(t) == 'on hold' and ticket_related_issue(t) is None:
    #    warning = "on hold ticket without related issue!".upper()

    template=Template("""${url} \"${desc}\"
                SU: ${su}
                Prio: ${prio}
                Age: ${age}
                Related issue: ${related}""")

    ticket_str = template.substitute({"url":ticket_url(t),
                         "desc": ticket_short_description(t),
                         "su": ticket_su(t),
                         "prio": ticket_priority(t),
                         "age": "%d days old" % age,
                         "related": None })

    if len(warning) > 0:
        ticket_str = ticket_str + "\n\t\t\tWARNING: %s" % warning

    return ticket_str
Beispiel #3
0
def print_submitted_tickets_report(start_date, end_date=datetime.now()):
    
    print "Producing EMI support summary report for period %s-%s. Please be patient..." % (start_date.strftime(date_format_str),end_date.strftime(date_format_str))
    print "EMI SUs covered (%d): \n%s" % (len(emi_support_units),"\n".join(sorted(emi_support_units.keys())))
    
    tickets = get_tickets(emi_submitted_tickets_in_period(start_date,end_date))
    
    status_classification = classify_status(tickets)
    priority_classification = classify_priority(tickets)
    su_classification = classify_su(tickets, sus=emi_support_units.keys())
    
    report_template = Template("""${numTickets} tickets were submitted in period ${startDate}-${endDate}. 
The status for these tickets is currently:
        ${numAssigned} assigned,
        ${numInProgress} in progress,
        ${numOnHold} on hold,
        ${numReopened} reopened,
        ${numWaitingForReply} waiting for reply,
        ${numSolved} solved,
        ${numUnsolved} unsolved,
        ${numClosed} closed,
        ${numVerified} verified.
        
The current priority classification of the above tickets is:
        
        ${numTopPriority} top priority,
        ${numVeryUrgent} very urgent,
        ${numUrgent} urgent,
        ${numLessUrgent} less urgent.""")
        
    keys = {'numTickets': len(tickets),
            'startDate': start_date.strftime(date_format_str),
            'endDate': end_date.strftime(date_format_str),
            'numAssigned': len(status_classification['assigned']),
            'numInProgress': len(status_classification['in progress']),
            'numOnHold': len(status_classification['on hold']),
            'numReopened': len(status_classification['reopened']),
            'numSolved': len(status_classification['solved']),
            'numUnsolved': len(status_classification['unsolved']),
            'numClosed' : len(status_classification['closed']),
            'numVerified': len(status_classification['verified']),
            'numWaitingForReply': len(status_classification['waiting for reply']),
            'numTopPriority': len(priority_classification['top priority']),
            'numVeryUrgent': len(priority_classification['very urgent']),
            'numUrgent': len(priority_classification['urgent']),
            'numLessUrgent': len(priority_classification['less urgent'])
            }
        
        
    print report_template.safe_substitute(keys)
    
    sus = sorted(su_classification.keys())
    print
    print "The above tickets are currently assigned to the following SUs:"
    for su in sus:
        print "\n%s: %d" % (su, len(su_classification[su]))
        for t in su_classification[su]:
            print "\thttps://ggus.eu/tech/ticket_show.php?ticket=%s (%s) %s " % (ticket_id(t), ticket_priority(t), ticket_status(t))
Beispiel #4
0
def print_on_hold_report():
    print "Producing on-hold tickets status report. Please be patient..."
    print "As of %s the following tickets are in on-hold status but don't have a related issue registered in GGUS." % datetime.now()
    tickets = get_tickets(open_on_hold_tickets())
    for t in filter(lambda x:ticket_related_issue(x) is None, sorted(tickets, key=ticket_su)):
        ggus_t = get_ggus_ticket(ticket_id(t))
        assigned_time = ggus_t.get_sla_compliance_values()[ticket_su(t)].assigned_time
        print "%-22s: https://ggus.eu/tech/ticket_show.php?ticket=%s ( %-3d days old ) %-15s %-15s \"%s\"" %(ticket_su(t),
                                                                                           ticket_id(t),
                                                                                           (datetime.now()-assigned_time).days,
                                                                                           ticket_priority(t),
                                                                                           ticket_status(t),
                                                                                           ticket_short_description(t))
Beispiel #5
0
def print_eta_status_report():
    print "Producing ETA status report. Please be patient..."
    
    tickets = get_tickets(open_very_urgent_and_top_priority_tickets())
    print "As of %s there are %d very urgent and top priority tickets which have ETA not set." % (datetime.now(), len(tickets))
    print
    for t in filter(lambda x:ticket_eta(x) is None, sorted(tickets, key=ticket_priority)):
        ggus_t = get_ggus_ticket(ticket_id(t))
        assigned_time = ggus_t.get_sla_compliance_values()[ticket_su(t)].assigned_time
        print "%-22s: https://ggus.eu/tech/ticket_show.php?ticket=%s ( %-3d days old ) %-15s %-18s \"%s\"" %(ticket_su(t),
                                                                                           ticket_id(t),
                                                                                           (datetime.now()-assigned_time).days,
                                                                                           ticket_priority(t),
                                                                                           ticket_status(t),
                                                                                           ticket_short_description(t))
Beispiel #6
0
def print_ksa_1_2(start_date,end_date=datetime.now()):
    print >>sys.stderr, "Producing KSA1.2 kpi csv file for period %s-%s. Please be patient..." % (format_date(start_date),format_date(end_date))
    
    csv_header = "su,%s" % ','.join(priorities)

    try:    
        tickets = get_tickets(third_level_closed_tickets_in_period(start_date,end_date))
    
    except WebFault:
        print >> stderr, "No closed tickets found in period %s-%s" % (format_date(start_date), format_date(end_date))
        return
    
    su_classification = classify_su(tickets)
    
    sus = sorted(su_classification.keys(), key=str.lower)
    print csv_header
    
    for su in sus:
        prios = classify_priority(su_classification[su])
        print "%s,%d,%d,%d,%d" % (su,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[0]]]).days,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[1]]]).days,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[2]]]).days,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[3]]]).days)
Beispiel #7
0
def print_assigned_tickets_report(assigned_priority_classification=None):
    
    now = datetime.now()
    
    if assigned_priority_classification is None:
        assigned_priority_classification = {}
        for i in priorities:
            assigned_priority_classification[i] = []
        
        for t in get_tickets(emi_third_level_assigned_tickets()):
            assigned_priority_classification[ticket_priority(t)].append(t)
    
    for p in priorities:
        if len(assigned_priority_classification[p]) == 0:
            continue
        else:
            print p, ":"
            num_violations = 0
            for t in assigned_priority_classification[p]:
                
                ggus_ticket = get_ggus_ticket(ticket_id(t))
                
                assigned_time = ggus_ticket.get_sla_compliance_values()[ticket_su(t)].assigned_time
                bc = BusinessCalendar(assigned_time)
                
                resolution_date = bc.add_business_time(sla_constraints[p])
                
                if resolution_date >= now:
                    sla_violation_string = "SLA check: OK (Assigned on: %s. To be taken in charge before %s)" % (assigned_time, resolution_date)
                else:
                    if now.day != resolution_date.day:
                        bd_delay = BusinessCalendar(resolution_date).count_business_days(now)
                        delay = "%s work days" % bd_delay
                    else:
                        delay = "%s hours" % (now - resolution_date)
                    
                    sla_violation_string = "SLA VIOLATION: Delay: %s (Assigned on: %s. Had to be taken in charge before %s)" % (delay, assigned_time, resolution_date)
                    num_violations = num_violations + 1
                
                print "\t(%s) \"%s\" https://ggus.eu/tech/ticket_show.php?ticket=%s\n\t%s" % (ticket_su(t),
                                                                                              ticket_short_description(t),
                                                                                              ticket_id(t),
                                                                                              sla_violation_string)
                print
            
            print "Of the %d %s tickets, %d violate the SLA " % (len(assigned_priority_classification[p]), p, num_violations)
            print
Beispiel #8
0
def print_su_classification(su_class):
    
    sus = sorted(su_class.keys(), key=str.lower)
    print
    print "# Ticket count per SU:"
    print
    for su in sus:
        if len(su_class[su]) == 0:
            continue
        print '%s: %s' % (su, len(su_class[su]))
    print
    
    print "# Ticket list per SU:"
    print
    for su in sus:
        if len(su_class[su]) == 0:
            continue
        ticket_ids = ",".join(map(lambda x: ticket_id(x), su_class[su]))
        print '%s: %s' % (su, ticket_ids)
    print
Beispiel #9
0
def ticket_resolution_delay(ticket):
    ggus_ticket = get_ggus_ticket(ticket_id(ticket))
    return ggus_ticket_resolution_delay(ggus_ticket)
Beispiel #10
0
     
 except WebFault, e:
     print >>stderr, "Error query for all EMI tickets: %s" % e
     exit(-1)
 
 su_classification = classify_su(tickets,emi_support_units)
 print_su_classification(su_classification)
 print
 
 sus = sorted(su_classification.keys(), key=str.lower)
 
 start_time = time.time()
 print "su;ticket_url;status;priority;creation_time;last_assigned_time;solution_time;time_to_solution_in_days;sla_delay_in_hours"
 for su in sus:
     for t in su_classification[su]:
         ggus_ticket = get_ggus_ticket(ticket_id(t))
         
         if ggus_ticket.solution_time():
             time_to_solution = "%d" % ggus_ticket.solution_time().days
         else:
             time_to_solution = ""
             
         last_solution_time = ggus_ticket.last_solution_time()
         if not last_solution_time:
             last_solution_time = ""
         
         delay_in_minutes = ggus_ticket_resolution_delay(ggus_ticket)
          
         print "%s;%s;%s;%s;%s;%s;%s;%s;%s" % (su,
                                               ticket_url(t),
                                               ticket_status(t),