コード例 #1
0
def main(args):

    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    if not args:
        print  USAGE
        sys.exit(9)
    # specify the Rally server and credentials
    server, username, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % opt for opt in [server, username, '********', workspace]])
    rally = Rally(server, user=username, password=password, workspace=workspace, warn=False)
    rally.enableLogging('rally.hist.chgsets')  # name of file you want the logging to go to

    repo_name = args.pop(0)
    since = None
    if args:
        since = args.pop(0)
        try:
            days = int(since)
            now = time.time()
            since_ts = now - (days * 86400)
            since = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime(since_ts))
        except:
            since = None

    showRepoItems(rally, repo_name, workspace=workspace, limit=ITEM_LIMIT, since_date=since)
コード例 #2
0
ファイル: rallyfire.py プロジェクト: lenciel/pyral
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])
    # add in the debug=True keyword arg if you want more verbiage ...
    rally = Rally(server, user, password, workspace=workspace, project=project, debug=True) 

    workspace = rally.getWorkspace()
    print "Workspace: %s " % workspace.Name
    #print "Workspace: %12.12s   %-18.18s    (%s)" % (workspace.oid, workspace.Name, workspace.ref)

    project = rally.getProject()
    print "Project  : %s " % project.Name
    #print "Project  : %12.12s   %-18.18s    (%s)" % (project.oid, project.Name, project.ref)

    # uncomment this to see all of your accessible workspaces and projects
#    workspaces = rally.getWorkspaces()
#    for workspace in workspaces:
#        print " ", workspace.Name
#        projects = rally.getProjects(workspace=workspace.Name)
#        if projects:
#            print ""
#            print "    Projects:"
#            for project in projects:
#                print "     ", project.Name
#        else:
#            print "  No projects"
#        print ""

    sys.exit(0)
コード例 #3
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging('rally.hist.statecount')  # name of file you want logging to go to

    if not args:
        errout(USAGE)
        sys.exit(1)

    rally.setWorkspace(workspace)
    rally.setProject(project)

    artifact_type = args[0]
    if artifact_type not in VALID_ARTIFACT_TYPES:
        errout(USAGE)
        errout('The artifact_type argument must be one of: %s\n' % ", ".join(VALID_ARTIFACT_TYPES))
        sys.exit(1)
        
    art_type = artifact_type[:]
    state = 'State'  # default to this and change below if necessary
    if artifact_type in ['Story', 'UserStory', 'HierarchicalRequirement']:
        artifact_type = 'HierarchicalRequirement'
        state = 'ScheduleState'

    t_zero = time.time()
    state_values = rally.getAllowedValues(artifact_type, state)
    t_one = time.time()
    av_time = t_one - t_zero

    show_counts(rally, artifact_type, state, state_values, av_time)
コード例 #4
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]

    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace)
    rally.enableLogging("rally.history.blddefs")

    for workspace, project in wps:
        print "workspace: %s  project: %s" % (workspace, project)
        rally.setWorkspace(workspace)
        response = rally.get('BuildDefinition', fetch=True, 
                             order='Name',
                             workspace=workspace, 
                             project=project)
        if response.errors:
            print response.errors
            sys.exit(9)

        for builddef in response:
            if builddef.Project.Name != project:
                continue
            if builddef.LastStatus == "NO BUILDS":
                print "NO BUILDS"
                continue
            #print builddef.oid, builddef.Name, builddef.LastStatus
            lbt = builddef.LastBuild.CreationDate.split('T')
            last_build_time = "%s %s" % (lbt[0], lbt[1][:5] )
            bd_name = "%-24.24s" % builddef.Name
            status  = "%-10.10s" % builddef.LastStatus
            print builddef.oid, builddef.CreationDate[:10], \
                  bd_name, status, last_build_time, len(builddef.Builds)

        print "\n"
コード例 #5
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]

    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace)
    rally.enableLogging("rally.history.blddefs")

    for workspace, project in wps:
        rally.setWorkspace(workspace)
        print "workspace: %s  project: %s\n" % (workspace, project)
        response = rally.get('BuildDefinition', fetch=True, 
                             query='Project.Name = "%s"' % project, 
                             order='Name', workspace=workspace, project=project)
        if response.errors:
            print response.errors
            sys.exit(9)

        print "%-12.12s   %-10.10s  %-36.36s %12s  %-20.20s  %s" % \
              ('BuildDef OID', 'CreateDate', 'BuildDefinition.Name', 'LastStatus', 'LastBuildDateTime', 'NumBuilds')
        print "%-12.12s   %-10.10s  %-36.36s   %10s  %-19.19s   %s" % \
              ('-' * 12, '-' * 10, '-' * 36, '-' * 10, '-' * 19, '-' * 9)
        for builddef in response:
            if builddef.LastStatus == "NO BUILDS":
                print "%s %s %-24.24s NO BUILDS" % \
                      (builddef.oid, builddef.CreationDate[:10], builddef.Name)
                continue
            lbt = builddef.LastBuild.CreationDate.split('T')
            last_build_time = "%s %s" % (lbt[0], lbt[1][:8] )
            bdf = "%12.12s   %-10.10s  %-36.36s %12s  %-20.20s    %4s"
            print bdf % (builddef.oid, builddef.CreationDate[:10], 
                  builddef.Name, builddef.LastStatus, last_build_time,
                  len(builddef.Builds))
コード例 #6
0
def main(args):

    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])

    if not args:
        print "You must supply an entity name!"
        sys.exit(1)

    query = ""
    target = args[0]
    if target in ['UserStory', 'User Story', 'Story']:
        target = "HierarchicalRequirement"
    if '/' in target:
        parent, entity = target.split('/', 1)
        target = entity
    query = 'ElementName = "%s"' % target

    try:
        rally = Rally(server, user=user, password=password)
    except Exception as ex:
        errout(str(ex.args[0]))       
        sys.exit(1)

    typedef = rally.typedef(target)
    showAttributes(typedef.Attributes)

    print ""
    print "-" * 64
    print ""
    for ix, ancestor in enumerate(typedef.inheritanceChain()):
        print "%s %s" % (" " * (ix*4), ancestor)
コード例 #7
0
def main(args):

    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])

    if not args:
        errout("ERROR: You must supply an entity name!\n")
        sys.exit(1)

    entity = args[0]
    if entity in ['UserStory', 'User Story', 'Story']:
        entity = "HierarchicalRequirement"
    #if '/' in entity:
    #    parent, entity = entity.split('/', 1)

    try:
        rally = Rally(server, user=user, password=password)
    except Exception as ex:
        errout(str(ex.args[0]))       
        sys.exit(1)

    schema_item = rally.typedef(entity)
    print schema_item
コード例 #8
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
    rally = Rally(server, user, password, workspace=workspace, warn=False)
    rally.enableLogging('rally.hist.articount')  # name of file you want logging to go to
    prog_opts = [opt for opt in args if opt.startswith('-')]
    byproject = False
    if '-byproject' in prog_opts:
        byproject = True
    
    #if not args:
    #    errout(USAGE)
    #    sys.exit(1)

    print ""
    workspaces = rally.getWorkspaces()
    for wksp in workspaces:
        rally.setWorkspace(wksp.Name)
        print wksp.Name
        print "=" * len(wksp.Name)
        projects = [None]
        if byproject:
            projects = rally.getProjects(workspace=wksp.Name)
        for project in projects:
            if project:
                print ""
                print project.Name
                print "    %s" % ('-' * len(project.Name))
            for artifact_type in COUNTABLE_ARTIFACT_TYPES:
                count = getArtifactCount(rally, artifact_type, project=project)
                print "       %-16.16s : %4d items" % (artifact_type, count)
        print ""
コード例 #9
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
    rally = Rally(server, user, password, workspace=workspace, warn=False)
    target_workspace, byproject, art_types = processCommandLineArguments(args)
    rally.enableLogging('rally.hist.articount')  # name of file you want logging to go to
    
    workspaces = rally.getWorkspaces()
    if target_workspace != 'all':
        hits = [wksp for wksp in workspaces if wksp.Name == target_workspace]
        if not hits:
            problem = "The specified target workspace: '%s' either does not exist or is not accessible"
            errout("ERROR: %s\n" % (problem % target_workspace))
            sys.exit(2)
        workspaces = hits

    for wksp in workspaces:
        print wksp.Name
        print "=" * len(wksp.Name)
        rally.setWorkspace(wksp.Name)
        projects = [None]
        if byproject:
            projects = rally.getProjects(workspace=wksp.Name)
        for project in projects:
            if project:
                print ""
                print "    %s" % project.Name
                print "    %s" % ('-' * len(project.Name))
            for artifact_type in art_types:
                count = getArtifactCount(rally, artifact_type, project=project)
                print "       %-16.16s : %4d items" % (artifact_type, count)
        print ""
コード例 #10
0
def main(args):
    options = [opt  for opt  in args if opt.startswith('--')]
    parms   = [parm for parm in args if parm not in options]
    server, username, password, workspace, project = rallySettings(options)
    rally = Rally(server, username, password, workspace=workspace, project=project)
    rally.enableLogging("rally.hist.add_tcrs")

    if len(parms) < 2:
        errout(USAGE)
        sys.exit(1)
    test_case_id, tcr_info_filename = parms
    if not os.path.exists(tcr_info_filename):
        errout("ERROR:  file argument '%s' does not exist.  Respecify using corrent name or path\n" % tcr_info_filename)
        errout(USAGE)
        sys.exit(2)
    try:
        with open(tcr_info_filename, 'r') as tcif:
            content = tcif.readlines()
        tcr_info = []
        # each line must have Build, Date, Verdict
        for ix, line in enumerate(content):
            fields = line.split(',')
            if len(fields) != 3:
                raise Exception('Line #%d has invalid number of fields: %s' % (ix+1, repr(fields)))
            tcr_info.append([field.strip() for field in fields])
    except Exception:
        errout("ERROR: reading file '%s'.  Check the permissions or the content format for correctness." % tcr_info_filename)
        errout(USAGE)
        sys.exit(2)

    test_case = rally.get('TestCase', query="FormattedID = %s" % test_case_id,
                          workspace=workspace, project=None, instance=True)
    if not test_case or hasattr(test_case, 'resultCount'):
        print "Sorry, unable to find a TestCase with a FormattedID of %s in the %s workspace" % \
              (test_case_id, workspace)
        sys.exit(3)

    wksp = rally.getWorkspace()

    for build, run_date, verdict in tcr_info:
        tcr_data = { "Workspace" : wksp.ref,
                     "TestCase"  : test_case.ref,
                     "Build"     : build,
                     "Date"      : run_date,
                     "Verdict"   : verdict
                   }
        try:
            tcr = rally.create('TestCaseResult', tcr_data)
        except RallyRESTAPIError, details:
            sys.stderr.write('ERROR: %s \n' % details)
            sys.exit(4)
        
        print "Created  TestCaseResult OID: %s  TestCase: %s  Build: %s  Date: %s  Verdict: %s" % \
               (tcr.oid, test_case.FormattedID, tcr.Build, tcr.Date, tcr.Verdict)
コード例 #11
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join([
        "|%s|" % item
        for item in [server, user, '********', workspace, project]
    ])
    rally = Rally(server, user,
                  password)  # specify the Rally server and credentials
    rally.enableLogging(
        'rally.hist.item')  # name of file you want logging to go to

    if len(args) != 1:
        errout(USAGE)
        sys.exit(2)
    ident = args[0]

    mo = FORMATTED_ID_PATT.match(ident)
    if mo:
        ident_query = 'FormattedID = "%s"' % ident
        entity_name = ARTIFACT_TYPE[mo.group('prefix')]
    else:
        errout('ERROR: Unable to determine ident scheme for %s\n' % ident)
        sys.exit(3)

    response = rally.get(entity_name, fetch=True, query=ident_query)

    if response.errors:
        errout("Request could not be successfully serviced, error code: %d\n" %
               response.status_code)
        errout("\n".join(response.errors))
        sys.exit(1)

    if response.resultCount == 0:
        errout('No item found for %s %s\n' % (entity_name, ident))
        sys.exit(4)
    elif response.resultCount > 1:
        errout('WARNING: more than 1 item returned matching your criteria\n')

    for item in response:
        for attr in COMMON_ATTRIBUTES:
            print "    %-16.16s : %s" % (attr, getattr(item, attr))
        attrs = [
            attr for attr in item.attributes() if attr not in COMMON_ATTRIBUTES
        ]
        for attr in sorted(attrs):
            attribute = getattr(item, attr)
            cn = attribute.__class__.__name__
            if cn[0] in string.uppercase:
                attribute = attribute.Name if cn != 'NoneType' else None
            print "    %-16.16s : %s" % (attr, attribute)
コード例 #12
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, username, password, workspace, project = rallySettings(options)
    print "|%s| |%s| |%s| |%s| |%s|" % (server, username, '********', workspace, project)
    rally = Rally(server, username, password, workspace=workspace)     # specify the Rally server and credentials
    rally.enableLogging('rally.hist.periscope')  # name of file for logging content

    for workspace in rally.getWorkspaces():
        print "%s %s" % (workspace.oid, workspace.Name)
        for project in rally.getProjects(workspace=workspace.Name):
            print "    %12.12s  %s" % (project.oid, project.Name)
        print ""
コード例 #13
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, username, password, workspace, project = rallySettings(options)
    #print "|%s| |%s| |%s| |%s| |%s|" % (server, username, password, workspace, project)
    print "|%s| |%s| |%s| |%s| |%s|" % (server, username, '********', workspace, project)
    rally = Rally(server, username, password)     # specify the Rally server and credentials
    rally.enableLogging('rally.hist.periscope')  # name of file for logging content

    for workspace in rally.getWorkspaces():
        print "%s %s" % (workspace.oid, workspace.Name)
        for project in rally.getProjects(workspace=workspace.Name):
            print "    %12.12s  %s" % (project.oid, project.Name)
コード例 #14
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
    rally = Rally(server, user, password, workspace=workspace)
    rally.enableLogging('rally.hist.getattachs') # name of file you want logging to go to

    if len(args) != 2:
        errout(USAGE)
        sys.exit(2)
    entity_name, ident = args
    if entity_name in STORY_ALIASES:
        entity_name = 'HierarchicalRequirement'

    mo = OID_PATT.match(ident)
    if mo:
        ident_query = 'ObjectID = %s' % ident
    else:
        mo = FORMATTED_ID_PATT.match(ident)
        if mo:
            ident_query = 'FormattedID = "%s"' % ident
        else:
            errout('ERROR: Unable to determine ident scheme for %s\n' % ident)
            sys.exit(3)

    response = rally.get(entity_name, fetch=True, query=ident_query, 
                         workspace=workspace, project=project)

    if response.errors:
        errout("Request could not be successfully serviced, error code: %d\n" % response.status_code)
        errout("\n".join(response.errors))
        sys.exit(1)

    if response.resultCount == 0:
        errout('No item found for %s %s\n' % (entity_name, ident))
        sys.exit(4)
    elif response.resultCount > 1:
        errout('WARNING: more than 1 item returned matching your criteria\n')

    artifact = response.next()
    attachments = rally.getAttachments(artifact)
    for attachment in attachments:
        print "-" * 32
        print attachment.Name
        print "~" * len(attachment.Name)
        print attachment.Content
        print ""
        print "=" *  64
コード例 #15
0
ファイル: crtask.py プロジェクト: lenciel/pyral
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    if len(args) != 1:
        errout(USAGE)
        sys.exit(1)
    storyID = args[0]

    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging("rally.history.crtask")

    # For a task: Workspace, Project, WorkProduct, Name, State, TaskIndex are required;
    # Workspace cannot be specified in the JSON, it defaults to
    # the logged in account's Workspace setting
    # Project and WorkProduct must be object refs to relevant Rally Entity instances.
    # In this example the WorkProduct is a UserStory (HierarchicalRequirement).

    target_project = rally.getProject()
    target_story = rally.get('UserStory',
                             query='FormattedID = %s' % storyID,
                             instance=True)

    info = {
        "Project":
        target_project.ref,
        "WorkProduct":
        target_story.ref,
        "Name":
        "BigTaters",
        "State":
        "Defined",
        "TaskIndex":
        1,
        "Description":
        "Fly to Chile next week to investigate the home of potatoes.  Find the absolute gigantoidist spuds and bring home the eyes to Idaho.  Plant, water, wonder, harvest, wash, slice, plunge in and out of hot oil, drain and enjoy! Repeat as needed.",
        "Estimate":
        62.0,
        "Actuals":
        1.0,
        "ToDo":
        61.0,
        "Notes":
        "I have really only done some daydreaming wrt this task.  Sorry Jane, I knew you had big plans for Frankie's blowout BBQ next month, but the honeycomb harvest project is taking all my time."
    }

    print "Creating Task ..."
    task = rally.put('Task', info)
    print "Created  Task: %s   OID: %s" % (task.FormattedID, task.oid)
コード例 #16
0
def main(args):

    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])

    if not args:
        print "You must supply an entity name!"
        sys.exit(1)

    query = ""
    target = args[0]
    if target in ['UserStory', 'User Story', 'Story']:
        target = "HierarchicalRequirement"
    if '/' in target:
        parent, entity = target.split('/', 1)
        target = entity
    query = 'ElementName = "%s"' % target

    try:
        rally = Rally(server, user=user, password=password)
    except Exception as ex:
        errout(str(ex.args[0]))       
        sys.exit(1)
    #rally.enableLogging('rally.hist.typedefs')

    response = rally.get('TypeDefinition', fetch=ATTRIBUTE_FIELDS, query=query, pretty=True,
                                           project=None)
    if response.errors:
        errout("Request could not be successfully serviced, error code: %d\n" % response.status_code)
        errout("\n".join(response.errors))
        sys.exit(1)

    results = response.content[u'QueryResult'][u'Results']
    tdd = results[0]   # tdd <-- type def data

    attrs = tdd[u'Attributes']
    showAttributes(attrs)

    print ""
    print "-" * 64
    print ""
    leaf_td = response.next()
    chain = getHeritage(leaf_td, [])

    for ix, triad in enumerate(chain):
        parent, entity, attributes = triad
        print "%s %s" % (" " * (ix*4), entity)
コード例 #17
0
def main(args):

    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    if not args:
        print  USAGE
        sys.exit(9)
    # specify the Rally server and credentials
    server, username, password, workspace, project = rallySettings(options)
    #print " ".join(["|%s|" % opt for opt in [server, username, '********', workspace]])
    rally = Rally(server, user=username, password=password, workspace=workspace, warn=False)
    rally.enableLogging('rally.hist.chgsets')  # name of file you want the logging to go to

    repo_name = args.pop()

    showRepoItems(rally, repo_name, workspace=workspace, limit=ITEM_LIMIT)
コード例 #18
0
ファイル: showdefects.py プロジェクト: lenciel/pyral
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging("rally.history.showdefects")
    
    fields    = "FormattedID,State,Name,Severity,Priority", 
    criterion = 'State != Closed'

    response = rally.get('Defect', fetch=fields, query=criterion, order="FormattedID",
                                   pagesize=200, limit=400)

    for defect in response:
        print "%-6.6s  %-46.46s  %s" % (defect.FormattedID, defect.Name, defect.State)

    print "-----------------------------------------------------------------"
    print response.resultCount, "qualifying defects"
コード例 #19
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
    rally = Rally(server, user, password)      # specify the Rally server and credentials
    rally.enableLogging('rally.hist.item') # name of file you want logging to go to

    if len(args) != 1:
        errout(USAGE)
        sys.exit(2)
    ident = args[0]

    mo = FORMATTED_ID_PATT.match(ident)
    if mo:
        ident_query = 'FormattedID = "%s"' % ident
        entity_name = ARTIFACT_TYPE[mo.group('prefix')]
    else:
        errout('ERROR: Unable to determine ident scheme for %s\n' % ident)
        sys.exit(3)

    response = rally.get(entity_name, fetch=True, query=ident_query)

    if response.errors:
        errout("Request could not be successfully serviced, error code: %d\n" % response.status_code)
        errout("\n".join(response.errors))
        sys.exit(1)

    if response.resultCount == 0:
        errout('No item found for %s %s\n' % (entity_name, ident))
        sys.exit(4)
    elif response.resultCount > 1:
        errout('WARNING: more than 1 item returned matching your criteria\n')

    for item in response:
        for attr in COMMON_ATTRIBUTES:
            print "    %-16.16s : %s" % (attr, getattr(item, attr))
        attrs = [attr for attr in item.attributes() if attr not in COMMON_ATTRIBUTES]
        for attr in sorted(attrs):
            attribute = getattr(item, attr) 
            cn = attribute.__class__.__name__
            if cn[0] in string.uppercase:
                attribute = attribute.Name if cn != 'NoneType' else None
            print "    %-16.16s : %s" % (attr, attribute)
コード例 #20
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
    rally = Rally(server, user, password, workspace=workspace, version="1.30")  # specify the Rally server and credentials
    rally.enableLogging('rally.hist.creattach') # name of file you want logging to go to

    if len(args) != 2:
        errout('ERROR: You must supply an Artifact identifier and an attachment file name')
        errout(USAGE)
        sys.exit(1)

    target, attachment_file_name = args
    artifact = validateTarget(rally, target)

    me = rally.getUserInfo(username=user).pop(0)
    #print "%s user oid: %s" % (user, me.oid)

    att = rally.addAttachment(artifact, attachment_file_name)
    print "created Attachment: %s for %s" % (attachment_file_name, target)
コード例 #21
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])
    #rally = Rally(server, user, password, workspace=workspace, project=project, 
    #              verify_ssl_cert=False) 
    #rally = Rally(server, user, password, workspace=workspace, project=project, debug=True) 
    rally = Rally(server, user, password, workspace=workspace, project=project) 
    #rally = Rally(server, user, password, debug=True) 
    # add in the debug=True keyword arg if you want more verbiage ...
    #rally = Rally(server, user, password, workspace=workspace, project=project, debug=True) 
    specified_workspace = workspace

    workspace = rally.getWorkspace()
    print "Workspace: %s " % workspace.Name
    if specified_workspace != workspace.Name:
        print "    ** The workspace you specified: %s is not a valid workspace name for your account, using your default  workspace instead" % specified_workspace
    #print "Workspace: %12.12s   %-18.18s    (%s)" % (workspace.oid, workspace.Name, workspace.ref)

    project = rally.getProject()
    print "Project  : %s " % project.Name
    #print "Project  : %12.12s   %-18.18s    (%s)" % (project.oid, project.Name, project.ref)

    # uncomment this to see all of your accessible workspaces and projects
#    workspaces = rally.getWorkspaces()
#    for workspace in workspaces:
#        print " ", workspace.Name
#        projects = rally.getProjects(workspace=workspace.Name)
#        if projects:
#            print ""
#            print "    Projects:"
#            for project in projects:
#                print "     ", project.Name
#        else:
#            print "  No projects"
#        print ""

    sys.exit(0)
コード例 #22
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join([
        "|%s|" % item for item in [server, user, password, workspace, project]
    ])
    # add in the debug=True keyword arg if you want more verbiage ...
    rally = Rally(server,
                  user,
                  password,
                  workspace=workspace,
                  project=project,
                  debug=True)

    workspace = rally.getWorkspace()
    print "Workspace: %s " % workspace.Name
    #print "Workspace: %12.12s   %-18.18s    (%s)" % (workspace.oid, workspace.Name, workspace.ref)

    project = rally.getProject()
    print "Project  : %s " % project.Name
    #print "Project  : %12.12s   %-18.18s    (%s)" % (project.oid, project.Name, project.ref)

    # uncomment this to see all of your accessible workspaces and projects
    #    workspaces = rally.getWorkspaces()
    #    for workspace in workspaces:
    #        print " ", workspace.Name
    #        projects = rally.getProjects(workspace=workspace.Name)
    #        if projects:
    #            print ""
    #            print "    Projects:"
    #            for project in projects:
    #                print "     ", project.Name
    #        else:
    #            print "  No projects"
    #        print ""

    sys.exit(0)
コード例 #23
0
ファイル: statecounts.py プロジェクト: lenciel/pyral
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    print " ".join([
        "|%s|" % item
        for item in [server, user, '********', workspace, project]
    ])
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging(
        'rally.hist.statecount')  # name of file you want logging to go to

    if not args:
        errout(USAGE)
        sys.exit(1)

    rally.setWorkspace(workspace)
    rally.setProject(project)

    artifact_type = args[0]
    if artifact_type not in VALID_ARTIFACT_TYPES:
        errout(USAGE)
        errout('The artifact_type argument must be one of: %s' %
               ", ".join(VALID_ARTIFACT_TYPES))
        sys.exit(1)

    art_type = artifact_type[:]
    state = 'State'  # default to this and change below if necessary
    if artifact_type in ['Story', 'UserStory', 'HierarchicalRequirement']:
        artifact_type = 'HierarchicalRequirement'
        state = 'ScheduleState'

    t_zero = time.time()
    state_values = rally.getAllowedValues(artifact_type, state).keys()
    t_one = time.time()
    av_time = t_one - t_zero

    show_counts(rally, artifact_type, state, state_values, av_time)
コード例 #24
0
ファイル: showdefects.py プロジェクト: lenciel/pyral
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging("rally.history.showdefects")

    fields = "FormattedID,State,Name,Severity,Priority",
    criterion = 'State != Closed'

    response = rally.get('Defect',
                         fetch=fields,
                         query=criterion,
                         order="FormattedID",
                         pagesize=200,
                         limit=400)

    for defect in response:
        print "%-6.6s  %-46.46s  %s" % (defect.FormattedID, defect.Name,
                                        defect.State)

    print "-----------------------------------------------------------------"
    print response.resultCount, "qualifying defects"
コード例 #25
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    if len(args) != 1:
        errout(USAGE)
        sys.exit(1)

    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging("rally.history.uptask")

    taskID = args.pop()  # for this example use the FormattedID
    print "attempting to update Task: %s" % taskID

    #
    # following assumes there is:
    #     a User in the system whose DisplayName is 'Crandall',
    #     a UserStory with a FormattedID of S12345,
    #     a Release with a name of 'April-A',
    #    an Iteration with a Name of 'Ivanhoe'
    # within the current Workspace and Project.
    #
    owner_name = 'Crandall'
    storyID = 'S12345'
    release_target = 'April-A'
    iteration_targe = 'Ivanhoe'

    target_workspace = rally.getWorkspace()
    target_project = rally.getProject()
    target_owner = rally.getUserInfo(name=owner_name).pop(
        0)  # assume a unique match...

    release = rally.get('Release',
                        query='Name = %s' % release_target,
                        instance=True)
    iteration = rally.get('Iteration',
                          query='Name = %s' % iteration_target,
                          instance=True)
    target_story = rally.get('UserStory',
                             query='FormattedID = %s' % storyID,
                             instance=True)

    info = {
        "Workspace": target_workspace.ref,
        "Project": target_project.ref,
        "FormattedID": taskID,
        "Name": "Stamp logo watermark on all chapter header images",
        "Owner": target_owner.ref,
        "Release": release.ref,
        "Iteration": iteration.ref,
        "WorkProduct": target_story.ref,
        "State": "Completed",
        "Rank": 2,
        "TaskIndex": 2,
        "Estimate": 18.0,
        "Actuals": 2.5,
        "ToDo": 15.5,
        "Notes": "Bypass any GIFs, they are past end of life date",
        "Blocked": "false"
    }

    ##    print info

    try:
        task = rally.update('Task', info)
    except RallyRESTAPIError, details:
        sys.stderr.write('ERROR: %s \n' % details)
        sys.exit(2)
コード例 #26
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args    = [arg for arg in args if arg not in options]
    if len(args) != 1:
        errout(USAGE)
        sys.exit(1)

    server, user, password, workspace, project = rallySettings(options)
    rally = Rally(server, user, password, workspace=workspace, project=project)
    rally.enableLogging("rally.history.uptask")

    taskID = args.pop()   # for this example use the FormattedID
    print "attempting to update Task: %s" % taskID

    #
    # following assumes there is:
    #     a User in the system whose DisplayName is 'Crandall',
    #     a UserStory with a FormattedID of S12345, 
    #     a Release with a name of 'April-A', 
    #    an Iteration with a Name of 'Ivanhoe' 
    # within the current Workspace and Project.
    #
    owner_name = 'Crandall'
    storyID    = 'S12345'
    release_target  = 'April-A'
    iteration_targe = 'Ivanhoe'

    target_workspace = rally.getWorkspace()
    target_project   = rally.getProject()
    target_owner = rally.getUserInfo(name=owner_name).pop(0) # assume a unique match...

    release      = rally.get('Release',   query='Name = %s' % release_target,   instance=True)
    iteration    = rally.get('Iteration', query='Name = %s' % iteration_target, instance=True)
    target_story = rally.get('UserStory', query='FormattedID = %s' % storyID,   instance=True)

    info = {
             "Workspace"     : target_workspace.ref,
             "Project"       : target_project.ref,
             "FormattedID"   : taskID,
             "Name"          : "Stamp logo watermark on all chapter header images",
             "Owner"         : target_owner.ref,
             "Release"       : release.ref,
             "Iteration"     : iteration.ref,
             "WorkProduct"   : target_story.ref,
             "State"         : "Completed",
             "Rank"          : 2,
             "TaskIndex"     : 2,
             "Estimate"      : 18.0,
             "Actuals"       : 2.5,
             "ToDo"          : 15.5,
             "Notes"         : "Bypass any GIFs, they are past end of life date",
             "Blocked"       : "false"
           }

##    print info   

    try:
        task = rally.update('Task', info)
    except RallyRESTAPIError, details:
        sys.stderr.write('ERROR: %s \n' % details)
        sys.exit(2)
コード例 #27
0
    def import_schedule(self):
        self.schedule = models.Schedule()
        start_time = None

        options = ['--config=%s' % self.handle]
        server, user, password, workspace, project = rallySettings(options)

        rally = Rally(server, user, password, workspace=workspace, project=project)

        rally_iter = self.options['rally_iter']
        self.schedule.name = rally_iter.strip()
        query_criteria = 'Iteration.Name = "%s"' % rally_iter

        response = rally.get('Iteration', fetch=True,
                             query='Name = "%s"' % rally_iter)
        if response.errors:
            sys.stdout.write("\n".join(response.errors))
            sys.exit(1)

        for iteration in response:
            print 'Iteration: %s (starts %s)' % (iteration.Name, iteration.StartDate)
            start_time = datetime.datetime.combine(
                datetime.datetime.strptime(iteration.StartDate[:10], '%Y-%m-%d'),
                datetime.time(8))
            break

        response = rally.get('UserStory', fetch=True, query=query_criteria, order="Rank")

        if response.errors:
            sys.stdout.write("\n".join(response.errors))
            sys.exit(1)

        index = 1
        if not start_time:
            start_time = datetime.datetime.combine(datetime.date.today(), datetime.time(8))
        max_end_time = start_time
        self.schedule.dStart = start_time

        for story in response:
            print story.Name
            t = models.Task(self.schedule, level=1)
            t.index = index
            index += 1
            t.name = story.Name.strip()
            t.dStart = start_time

            max_st_end_time = start_time
            story.Tasks.sort(key=lambda x: x.TaskIndex)
            for task in story.Tasks:
                print '-- %s  |  %sh  |  %s' % (task.Name, task.Estimate, task.Owner.Name)
                t_in = models.Task(self.schedule, level=2)
                t_in.index = index
                index += 1
                t_in.name = task.Name.strip()
                t_in.dStart = start_time
                t_in.dFinish = start_time + datetime.timedelta(hours=float(task.Estimate))
                max_st_end_time = max(max_end_time, t_in.dFinish)

                # look for resource
                resource_id = None
                for r_id, resource in self.schedule.resources.items():
                    if resource == task.Owner.Name:
                        resource_id = r_id
                        break
                if not resource_id:
                    resource_id = len(self.schedule.resources) + 1
                    self.schedule.resources[resource_id] = str(task.Owner.Name)

                t_in.resource = resource_id

                t.tasks.append(t_in)
            print ''
            t.dFinish = max_st_end_time
            max_end_time = max(max_end_time, t.dFinish)
            self.schedule.tasks.append(t)

        self.schedule.dFinish = max_end_time
        return self.schedule
コード例 #28
0
ファイル: gettc.py プロジェクト: ahonnecke/home
import sys
from pyral import Rally, rallySettings
options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args = [arg for arg in sys.argv[1:] if arg not in options]
server, user, password, workspace, project = rallySettings(options)
rally = Rally(server, user, password, workspace=workspace, project=project)
rally.enableLogging('mypyral.log')
コード例 #29
0
import requests
from pyral import Rally, rallySettings

# Required for Perforce
from P4 import P4, P4Exception

# Initialise Perforce
p4 = P4()
p4.user = '******'
p4.client = 'Tristan.Gaffney.vc7.Main.LDNRS010'
p4.exception_level = 2

#Initialise Rally
from pyral import Rally, rallySettings
options = []
server, user, password, workspace, project = rallySettings(options)
user = "******"
password = "******"
rally = Rally(server, user, password, workspace=workspace, project=project)
rally.enableLogging('mypyral.log')


def extractChangeLists(startChangelist, endChangelist):
    try:
        start = "3.71.3.130"
        end = "3.71.3.140"

        p4.connect()
        completed = {}
        contributions = {}