예제 #1
0
def iter_index(items, fun, *args):
    update(0, len(items))
    for i, item in enumerate(items):
        try:
            fun(item, i, *args)
        except Exception as e:
            print color.err("Error: ") + "Exception encountered in progress iter_index!"
            print e.message
        update(i + 1, len(items))
    finish()
예제 #2
0
def check_error(json_rep):
    try:
        if json_rep['kind'] == 'error':
            print '\n' + color.err('JSON ERROR: ') + str(json_rep)
            raise RuntimeError('Json reply was an error!')
    except TypeError:
        # if there is no kind, there was no error
        pass
예제 #3
0
def run_session(section):
    if section.has_estimator_id():
        print color.success_blue('# ') + 'Loaded existing Estimator session'
    else:
        print color.success_blue('# ') + 'No existing Estimator session found, starting new session...'
        print color.success_blue('# ') + 'Making backup of Queue and Backlog...'
        backup.backup_project(section.queue)
        progress.update(1, 2)
        backup.backup_project(section.backlog)
        progress.finish()

        try:
            section.estimator = create_estimator(section)
            section.write_estimator_id()
            
            try:
                print color.success_blue('# ') + 'Sharing Estimator with all members in account...'
                share_estimator_with_account(section)
            except Exception:
                pass
        except RuntimeError:
            est_id = raw_input(color.err('ERROR: ') + 'Estimator project already exists, but was not found in the config file. Please enter id of the Estimator project: ')
            section.estimator = piv.Project.load(int(est_id))
            section.write_estimator_id()
        
        section.imported = False
        section.write_imported()
    
    if not section.has_imported():
        stories = section.estimator.fetch_stories()
        if len(stories) != 0:
            print color.success_blue('# ') + 'Estimator project has not imported all the stories from Queue and Backlog; continuing imports...'
            
        init(section)
        section.imported = True
        section.write_imported()
    
    print color.success_blue('# ') + 'Estimator project at: https://www.pivotaltracker.com/n/projects/' + str(section.estimator.id)
    
    query_user_input(section)

    print color.success_blue('# ') + 'Making backup of Estimator...'
    backup.backup_project(section.estimator)
    progress.finish()
    
    finalize(section)