Esempio n. 1
0
def main():

    parser = get_parser()
    parser.add_argument('ticket_id', metavar='ticket_id',
            type=int,
            help='Ticket ID')
    parser.add_argument('-a', '--action', dest='action',
            help='Action on ticket')
    args = parser.parse_args()

    BASE="https://dev.inigo-tech.com/trac/%(project)s"
    project = args.project
    
    user, passwd = get_auth(args.username, args.password)

    conf = TracConfig(BASE % dict(project=project), user, passwd)
    ticket_server = TracTicketXMLRPC(conf)

    ticket = ticket_server.get(args.ticket_id)

    print "URL: %s" % (ticket.url)
    print "Summary: %s" % (ticket.summary)
 
    available_actions = list(action_keys(ticket_server.available_actions(
                                        args.ticket_id)))
    if args.action and (args.action not in available_actions):
        print 'Invalid action "%s". Available actions are : %s' % (args.action,
                                ' , '.join(available_actions))
        return 1
 
    components = ticket_server.components()
    #components = [field['options'] for field in fields if field['name']=='component'][0]
    milestones = ticket_server.milestones()

    hours = raw_input("Effective hours: ")
    comment = editor_input("Please enter a comment above")
    
    print "\n\n====================\n"
    print "URL: %s" % ticket.url
    print "Summary : %s" % ticket.summary
    print "Effective Hours: %s" % hours
    print "Comment\t:\n%s" % (indent(comment))
    
    proceed = raw_input("Is this correct? (y/n)")
    if proceed.strip().lower()[0] != 'y':
       return
    
    #propertykeys = ['status', 'totalhours', 'description', 'reporter', 'cc', 'milestone', 'component', 'summary', 'hours', 'owner', 'internal', 'billable', 'keywords', 'estimatedhours', 'type', 'priority']
    if args.action:
        ticket.update(comment, hours=hours, action=args.action)
    else:
        ticket.update(comment, hours=hours)

    print "\nTicket %s updated" % ticket.url
def main():

    parser = get_parser()
    args = parser.parse_args()

    BASE="https://dev.inigo-tech.com/trac/%(project)s"
    project = args.project
    
    user, passwd = get_auth(args.username, args.password)

    conf = TracConfig(BASE % dict(project=project), user, passwd)
    ticket_server = TracTicketXMLRPC(conf)
    
    components = ticket_server.components()
    #components = [field['options'] for field in fields if field['name']=='component'][0]
    milestones = ticket_server.milestones()

    summary = raw_input("Summary: ")
    hours = raw_input("Effective hours: ")
    component = selection_input("Select component: ",components)
    milestone = selection_input("Select milestone: ",milestones)
    description = editor_input("Please enter a description above")
    
    print "\n\n====================\n"
    print "Summary : %s" % summary
    print "Effective Hours: %s" % hours
    print "Component: %s" % component
    print "Milestone: %s" % milestone
    print "Description\t:\n\n%s" % ("     %s" % description.replace('\n','\n     '))
    
    proceed = raw_input("Is this correct? (y/n)")
    if proceed.strip().lower()[0] != 'y':
       return
    
    #propertykeys = ['status', 'totalhours', 'description', 'reporter', 'cc', 'milestone', 'component', 'summary', 'hours', 'owner', 'internal', 'billable', 'keywords', 'estimatedhours', 'type', 'priority']
    
    tid = ticket_server.create(summary,description + 
                                '\n\n TimeTracker : New Ticket', 
                                component=component,
                                milestone=milestone)

    ticket = ticket_server.get(tid)

    ticket.update('TimeTracker : Adding time and closing ticket', hours=hours,
                        action='resolve')

    print "\nTicket created at %s/ticket/%s and closed" % (BASE % dict(project=project),tid)