コード例 #1
0
def commit(ref, message, diff):
    fields = parse(message)
    if not reduce(operator.and_, map(lambda x: x in fields.keys(), REQUIRED_FIELDS)):
        raise Exception("HENRY: Missing fields in commit message")
    uID = firebase_utils.getUserID(ref, fields["email"])
    pID = firebase_utils.getProjectID(ref, fields["project"])
    mID = firebase_utils.getMilestoneID(ref, pID, fields["milestone"])
    tID = firebase_utils.getTaskID(ref, pID, mID, fields["task"])
    firebase_utils.commit(
        ref,
        fields["message"],
        uID,
        pID,
        mID,
        tID,
        fields["hours"],
        fields["status"],
        fields["added_lines_of_code"],
        fields["removed_lines_of_code"],
    )
    if "pp" in fields:
        uID = firebase_utils.getUserID(ref, fields["pp"])
        firebase_utils.commit(
            ref,
            fields["message"],
            uID,
            pID,
            mID,
            tID,
            fields["hours"],
            fields["status"],
            fields["added_lines_of_code"],
            fields["removed_lines_of_code"],
        )
コード例 #2
0
def commit(ref,message,diff):
    fields = parse(message)
    if not reduce(operator.and_,map(lambda x: x in fields.keys(),REQUIRED_FIELDS)):
        raise Exception('HENRY: Missing fields in commit message')
    uID = firebase_utils.getUserID(ref,fields['email'])
    pID = firebase_utils.getProjectID(ref,fields['project'])
    mID = firebase_utils.getMilestoneID(ref,pID,fields['milestone'])
    tID = firebase_utils.getTaskID(ref,pID,mID,fields['task'])
    firebase_utils.commit(ref,fields['message'],uID,pID,mID,tID,fields['hours'],fields['status'],fields['added_lines_of_code'],fields['removed_lines_of_code'])
コード例 #3
0
def editHours(ref):
    email = git_utils.getEmail()
    uID = firebase_utils.getUserID(ref,email)
    pID = readProjectID()
    if pID == None:
        print 'Henry repository not initialized or corrupted'
        return
    mID = promptForMilestone(ref,pID)
    if mID == None:
        return
    tID = promptForTask(ref,uID,pID,mID)
    current = firebase_utils.getCurrentHourEstimate(ref,pID,mID,tID)
    update = promptForUpdate(current)
    if update != None:
        firebase_utils.setCurrentHourEstimate(ref,update,uID,pID,mID,tID)
コード例 #4
0
 ref = firebase.FirebaseApplication(firebase_url,None)
 sys.argv = [v.strip() for v in sys.argv]
 try:
     if len(sys.argv) == 1:
         usage()
     elif sys.argv[1] == 'init':
         try:
             pID = firebase_utils.getProjectID(ref,sys.argv[2]) 
         except:
             traceback.print_exc(file=sys.stdout)
             print 'HENRY Error: Invalid or nonexistant Henry project name'
             print '   henry init <project name>'
             exit(1)
         try:
             email = git_utils.getEmail()
             userID = firebase_utils.getUserID(ref,email)
         except:
             traceback.print_exc(file=sys.stdout)
             print 'HENRY Error: Invalid or unregistered Git email address'
             print '   henry init <project name>'
             exit(1)
         initialize_git(pID,OPSYS)
     elif sys.argv[1] in {'version','-version','--version','-v'}:
         version()
     elif sys.argv[1] in {'help','-help','--help','-h'}:
         helpmenu()
     elif sys.argv[1] in {'status'}:
         status(ref)
     elif sys.argv[1] in {'edit','edithours'}:
         editHours(ref)
     else:
コード例 #5
0
def prompt(ref):
    sys.stdin = open('/dev/tty')

    def_uID, def_pID, def_mID, def_tID, def_status = getDefaults()
   
    if def_uID != None:
        uID = def_uID
    else:
        sys.stdout.write('Email: ')
        sys.stdout.flush()
        email = raw_input()
        uID = firebase_utils.getUserID(ref,email)

    if def_pID != None:
        print 'Active projects (defaults to '+def_pID+'):'
    else:
        print 'Active projects:'
    sys.stdout.flush()
    idsByIndex = [] ; index = 1
    for pID, pName in firebase_utils.getActiveProjects(ref,uID).iteritems():
        print ' - '+str(index)+'. '+pName
        idsByIndex = idsByIndex + [pID]
        index = index + 1
    sys.stdout.write('Project: ')
    sys.stdout.flush()
    project = raw_input()
    if project.isdigit() and int(project) <= len(idsByIndex):
        pID = idsByIndex[int(project)-1]
    elif project == '' and def_pID != 0:
        pID = def_pID
    else:
        pID = firebase_utils.getProjectID(ref,project)

    if def_mID != None:
        print 'Active milestones (defaults to '+def_mID+'):'
    else:
        print 'Active milestones:'
    sys.stdout.flush()
    idsByIndex = [] ; index = 1
    for mID, mName in firebase_utils.getActiveMilestones(ref,uID,pID).iteritems():
        print ' - '+str(index)+'. '+mName
        idsByIndex = idsByIndex + [mID]
        index = index + 1
    sys.stdout.write('Milestone: ')
    sys.stdout.flush()
    milestone = raw_input()
    if milestone.isdigit() and int(milestone) <= len(idsByIndex):
        mID = idsByIndex[int(milestone)-1]
    elif milestone == '' and def_mID != 0:
        mID = def_mID
    else:
        mID = firebase_utils.getMilestoneID(ref,pID,milestone)

    if def_tID != None:
        def_task = firebase_utils.getTask(ref,pID,mID,def_tID)
        print 'Tasks assigned to you (defaults to '+def_task+'):'
    else:
        print 'Tasks assigned to you:'
    idsByIndex = [] ; index = 1
    for tID, tName in firebase_utils.getAssignedTasks(ref,uID,pID,mID).iteritems():
        print ' - '+str(index)+'. '+tName
        idsByIndex = idsByIndex + [tID]
        index = index + 1
    sys.stdout.write('Task: ')
    sys.stdout.flush()
    task = raw_input()
    if task.isdigit() and int(task) <= len(idsByIndex):
        tID = idsByIndex[int(task)-1]
    elif task == '' and def_tID != 0:
        tID = def_tID
    else:
        tID = getTaskID(pID,mID,task)


    sys.stdout.write('Hours: ')
    sys.stdout.flush()
    hours = raw_input()


    if def_status != None:
        print 'Select status (defaults to '+def_status+'):'
    else:
        print 'Select status:'
    possibleStatuses = ['New', 'Implementation', 'Testing', 'Verify', 'Regression', 'Closed']
    for i in range(len(possibleStatuses)):
        print ' - ' + str(i+1) + ': ', possibleStatuses[i]
    sys.stdout.write('Status: ')
    sys.stdout.flush()
    status = raw_input()
    if status.isdigit() and (int(status) <= len(possibleStatuses)):
        status = possibleStatuses[int(status)-1]
    elif status == '' and def_status != 0:
        status = def_status
    else:
        print 'HENRY: Invalid status, commit failed'
        exit(1)
    print 'I should be returning' 
    return uID,pID,mID,tID,hours,status
コード例 #6
0
def promptAsNecessary(ref,userID,projectID,hours,milestone,task,status,email):
    # mac/linux
    sys.stdin = open('/dev/tty')

    # windows
    #sys.stdin = open('CON')

    def_mID, def_tID, def_status = getDefaults()

    if hours == None:
        sys.stdout.write('Hours: ')
        sys.stdout.flush()
        hours = raw_input()

    # prompt for milestone if necessary
    if milestone == None:
        if def_mID != None:
            def_milestone = firebase_utils.getMilestone(ref,projectID,def_mID)
            print 'Active milestones (defaults to '+def_milestone+'):'
        else:
            print 'Active milestones:'
        sys.stdout.flush()
        idsByIndex = [] ; index = 1
        for mID, mName in firebase_utils.getActiveMilestones(ref,userID,projectID).iteritems():
            print ' - '+str(index)+'. '+mName
            idsByIndex = idsByIndex + [mID]
            index = index + 1
        sys.stdout.write('Milestone: ')
        sys.stdout.flush()
        milestone = raw_input()
        if milestone.isdigit() and int(milestone) <= len(idsByIndex):
            mID = idsByIndex[int(milestone)-1]
        elif milestone == '' and def_mID != 0:
            mID = def_mID
        else:
            mID = firebase_utils.getMilestoneID(ref,projectID,milestone)
    else:
        mID = firebase_utils.getMilestoneID(ref,projectID,milestone)

    # prompt for task if necessary
    if task == None:
        if def_tID != None and mID == def_mID:
            def_task = firebase_utils.getTask(ref,projectID,mID,def_tID)
            print 'Tasks assigned to you (defaults to '+def_task+'):'
        else:
            print 'Tasks assigned to you:'
        idsByIndex = [] ; index = 1
        for tID, tName in firebase_utils.getAssignedTasks(ref,userID,projectID,mID).iteritems():
            print ' - '+str(index)+'. '+tName
            idsByIndex = idsByIndex + [tID]
            index = index + 1
        sys.stdout.write('Task: ')
        sys.stdout.flush()
        task = raw_input()
        if task.isdigit() and int(task) <= len(idsByIndex):
            tID = idsByIndex[int(task)-1]
        elif task == '' and def_tID != 0:
            tID = def_tID
        else:
            tID = firebase_utils.getTaskID(projectID,mID,task)
    else:
        tID = firebase_utils.getTaskID(projectID,mID,task)

    # prompt for status if necessary
    if status == None:
        # New, Implementation, Testing, Verify, Regression, Closed'
        if def_status != None:
            print 'Select status (defaults to '+def_status+'):'
        else:
            print 'Select status:'
        possibleStatuses = ['New', 'Implementation', 'Testing', 'Verify', 'Regression', 'Closed']
        for i in range(len(possibleStatuses)):
            print ' - ' + str(i + 1) + ': ', possibleStatuses[i]
        sys.stdout.write('Status: ')
        sys.stdout.flush()
        status = raw_input()
        if status.isdigit() and (int(status) <= len(possibleStatuses)):
            status = possibleStatuses[int(status) - 1]
        elif status == '' and def_status != 0:
            status = def_status
        else:
            print 'HENRY: Invalid status, commit failed'
            exit(1)

    sys.stdout.write('Pair programmed? (y/n): ')
    sys.stdout.flush()
    response = raw_input()
    if response.lower()[0] == 'y':
        team_emails = firebase_utils.teamEmails(ref,projectID)
        team_emails = [e for e in team_emails if e != email]
        if not team_emails:
            print 'HENRY: No team members, are you sure you pair programmed?'
            exit(1)
        index = 1
        for e in team_emails:
            print ' - '+str(index)+'. '+e
            index = index+1
        sys.stdout.write('Partner: ')
        sys.stdout.flush()
        partner = raw_input()
        if partner.isdigit() and int(partner) <= len(team_emails):
            pp = firebase_utils.getUserID(ref,team_emails[int(partner)-1])
        elif partner in team_emails:
            pp = firebase_utils.getUserID(ref,partner)
        else:
            print 'HENRY: Invalid team member'
            exit(1)
    else:
        pp = None

    return hours,mID,tID,status,pp