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) server, username, password, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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)
def main(args): options = [opt for opt in args if opt.startswith('--')] server, username, password, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace) else: rally = Rally(server, user=username, password=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)))
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) != 2: errout( 'ERROR: You must supply an Artifact identifier and an attachment file name' ) errout(USAGE) sys.exit(1) target, attachment_file_name = args server, username, password, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging( 'rally.hist.creattach') # name of file you want logging to go to artifact = validateTarget(rally, target) me = rally.getUserInfo(username=username).pop(0) #print "%s user oid: %s" % (username, me.oid) att = rally.addAttachment(artifact, attachment_file_name) print("created Attachment: %s for %s" % (attachment_file_name, target))
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, username, password, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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 target_workspace = rally.getWorkspace() target_project = rally.getProject() info = { "FormattedID" : taskID, "State" : "In-Progress" } ## print info try: task = rally.update('Task', info) except RallyRESTAPIError, details: sys.stderr.write('ERROR: %s \n' % details) sys.exit(2)
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, apikey, workspace, project = rallyWorkset( options) rally = Rally(server, username, password, apikey=apikey, workspace=workspace, project=project) target = args.pop(0) fields = "FormattedID,State,Name,CreationDate,RevisionHistory,Revisions" criteria = "FormattedID = %s" % target defect = rally.get('Defect', fetch=fields, query=criteria, instance=True) print("%s %10.10s %-11s %s" % (defect.FormattedID, defect.CreationDate, defect.State, defect.Name)) print("") for rev in reversed(defect.RevisionHistory.Revisions): print("%d) %-22.22s %-16.16s %s\n" % \ (rev.RevisionNumber, rev.CreationDate.replace('T', ' '), rev.User.DisplayName, rev.Description))
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: errout("ERROR: You must supply an entity name!\n") sys.exit(1) server, username, password, apikey, workspace, project = rallyWorkset(options) try: if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) except Exception as ex: errout(str(ex.args[0])) sys.exit(1) entity = args[0] if entity in ['UserStory', 'User Story', 'Story']: entity = "HierarchicalRequirement" #if '/' in entity: # parent, entity = entity.split('/', 1) schema_item = rally.typedef(entity) print(schema_item)
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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("%-8.8s %-52.52s %s" % (defect.FormattedID, defect.Name, defect.State)) print("-----------------------------------------------------------------") print(response.resultCount, "qualifying defects")
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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 %-36.36s |%s|" % (project.oid, project.Name, project.State) print ""
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: errout("ERROR: You must supply an entity name!\n") sys.exit(1) server, user, password, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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
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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project) entity_name = 'Milestone' fields = 'FormattedID,Name,TargetProject,TargetDate,TotalArtifactCount' response = rally.get(entity_name, fetch=fields, order="TargetDate,FormattedID", project=project, projectScopeDown=True) 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 items found for %s\n' % entity_name) sys.exit(2) milestones = [item for item in response] sans_project = [mi for mi in milestones if not mi.TargetProject] with_project = [mi for mi in milestones if mi.TargetProject] with_project.sort(key=lambda mi: mi.TargetProject.Name) for item in (with_project + sans_project): proj_name = item.TargetProject.Name if item.TargetProject else "" print(" %15.15s %-6.6s %-36.36s %3d %-10.10s %s " % \ (item.oid, item.FormattedID, item.Name, item.TotalArtifactCount, item.TargetDate, proj_name))
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 "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 server, username, password, apikey, workspace, project = rallyWorkset(options) try: if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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)
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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)
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging( 'rally.hist.item') # 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') sys.exit(5) for item in response: print(item.details())
def initialize_rally(): print(f' - initializing Rally API ...') server, user, password, apikey, workspace, project = rallyWorkset([]) rally = Rally(server=server, apikey=apikey, workspace=workspace, project=project) return rally, workspace, project
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging("rally.hist.add_tcrs") if len(args) < 2: errout(USAGE) sys.exit(1) test_case_id, tcr_info_filename = args 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)
def connect_to_rally(commands): options = [arg for arg in commands if arg.startswith('--')] args = [arg for arg in commands if arg not in options] server, user, password, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project) return rally
def main(args): options = [opt for opt in sys.argv[1:] if opt.startswith('--')] args = [arg for arg in sys.argv[1:] if arg not in options] server, username, password, apikey, workspace, project = rallyWorkset(options) # if len(args) < 2: # errout(USAGE) # sys.exit(2) if "-h" in args or "--help" in args or len(args) < 1: parser = argparse.ArgumentParser() parser.add_argument("[Please input 2 Parameters]", help="This script is to Update a given Defect") parser.add_argument("userStoryID, PromotedImpactedEnvironment", help="Please provide required Defect attributes to update") result = parser.parse_args() sys.exit(2) # parser = argparse.ArgumentParser() # parser.add_argument("Description", help="This script is to Update a given Defect") # parser.add_argument("Update Defect", # help="Please provide required Defect attributes to update") # args = parser.parse_args() if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) projects = rally.getProjects(workspace) entity_name = 'UserStory' userStoryID, PromotedImpactedEnvironment = args[:2] userStory_data = {"FormattedID": userStoryID, "PromotedImpactedEnvironment": PromotedImpactedEnvironment } ident_query = 'FormattedID = "%s"' % userStoryID try: for proj in projects: # print(" %12.12s %s" % (proj.oid, proj.Name)) response = rally.get(entity_name, fetch=True, query=ident_query, workspace=workspace, project=proj.Name) if response.resultCount > 0: print("Workspace Name: %s , Project Name: %s , Entity Name: %s , User Story Id: %s" %(workspace, proj.Name, entity_name, userStoryID)) userStory = rally.update(entity_name, userStory_data, project=proj.Name) break except Exception: sys.stderr.write('ERROR: %s \n'+errout) sys.exit(1) print("\nUser Story %s updated with following attributes:" % userStoryID) print("FormattedID: " + userStoryID) print("PromotedImpactedEnvironment: " + PromotedImpactedEnvironment+"\n")
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging( 'rally.hist.item') # name of file you want logging to go to retdata = getPreCommit() if retdata != 0: print("Return Value: " + retdata) #entity_name, ident = args entity_name = 'Defect' ident_query = 'FormattedID = "%s"' % retdata 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)) retFlag = 0 if response.resultCount == 0: errout('No item found for %s %s\n' % (entity_name, retdata)) retFlag = 0 elif response.resultCount > 1: errout('WARNING: more than 1 item returned matching your criteria\n') retFlag = 0 else: print("Time to commit") retFlag = 1 if retFlag == 1: print("Commit here")
def main(args): options = [opt for opt in args if opt.startswith('--')] args = [arg for arg in args if arg not in options] entity = args.pop(0) attributes = args server, user, password, apikey, workspace, project = rallyWorkset(options) print(" ".join([ "|%s|" % item for item in [server, user, password, apikey, workspace, project] ])) #rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project, server_ping=False) rally = Rally(server, user, password, apikey=apikey, server_ping=False) rally.enableLogging( 'rally.hist.avl') # name of file you want the logging to go to target = entity if entity in ['Story', 'User Story', 'UserStory']: entity = "HierarchicalRequirement" target = entity mo = CAMEL_CASED_NAME_PATT.search(entity) if mo: txfm = re.sub(CAMEL_CASED_NAME_PATT, r'\1 \2', entity) print('transforming query target "%s" to "%s"' % (entity, txfm)) entity = txfm print("%s" % entity) response = rally.get('TypeDefinition', fetch="Name,Attributes", query='Name = "%s"' % entity) # could check for response.errors here... if response.errors: print("Errors: %s" % response.errors) if response.warnings: print("Warnings: %s" % response.warnings) td = response.next() for attribute in td.Attributes: attr_name = attribute.Name.replace(' ', '') if attributes and attr_name not in attributes: continue if attribute.AttributeType not in ['STATE', 'RATING', 'STRING']: continue allowed_values = rally.getAllowedValues(target, attr_name) if not allowed_values: continue print(" %-28.28s (%s)" % (attr_name, attribute.AttributeType)) for av in allowed_values: print(" |%s|" % av)
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, apikey, workspace, project = rallyWorkset(options) print " | ".join([server, username, password, workspace, project]) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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)
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, apikey, workspace, project = rallyWorkset(options) print(f'server: {server}') print(f'apikey: {apikey}') print(f'workspace: {workspace}') print(f'project : {project}') if apikey: #rally = Rally(server, apikey=apikey, workspace=workspace, project=project) rally = Rally(server, apikey=apikey, workspace=workspace) else: #rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally = Rally(server, user=username, password=password, workspace=workspace) rally.enableLogging('rally.hist.artifact') # name of file you want logging to go to if len(args) != 1: errout(USAGE) sys.exit(2) ident = args.pop(0) mo = FORMATTED_ID_PATT.match(ident) if mo: ident_query = 'FormattedID = "%s"' % ident else: errout('ERROR: Unable to detect a valid Rally FormattedID in your arg: %s\n' % ident) sys.exit(3) mo = re.match(r'^(?P<art_abbrev>DE|S|US|TA|TC|F|I|T)\d+$', ident) if not mo: errout('ERROR: Unable to extract a valid Rally artifact type abbrev in %s' % ident) sys.exit(4) art_abbrev = mo.group('art_abbrev') entity_name = ARTIFACT_TYPE[art_abbrev] response = rally.get(entity_name, fetch=True, query=ident_query, workspace=workspace) 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') sys.exit(5) for item in response: print(item.details())
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("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 server, username, password, apikey, workspace, project = rallyWorkset( options) print(" ".join([ "|%s|" % item for item in [server, username, password, apikey, workspace, project] ])) try: rally = Rally(server, username, password, apikey=apikey, workspace=workspace, server_ping=False) except Exception as ex: errout(str(ex.args[0])) sys.exit(1) sub_name = rally.subscriptionName() print("Subscription Name: %s" % sub_name) wksp = rally.getWorkspace() print("Workspace Name: %s" % wksp.Name) print("Entity: %s" % target) print("-----------") print("Attributes:") print("-----------") typedef = rally.typedef(target) showAttributes(rally, target, typedef.Attributes) print("") print("-" * 64) print("") for ix, ancestor in enumerate(typedef.inheritanceChain()): print("%s %s" % (" " * (ix * 4), ancestor))
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, apikey, workspace, project = rallyWorkset(options) #print(" ".join(["|%s|" % item for item in [server, user, password, apikey[:8], workspace, project]])) # If you want to use BasicAuth, use the following form #rally = Rally(server, user, password, workspace=workspace, project=project) # If you want to use API Key, you can use the following form #rally = Rally(server, apikey=apikey, workspace=workspace, project=project) # the following form of obtaining a Rally instance will use the apikey if it is present (non None) # otherwise it will use the user and password for BasicAuth # add in the debug=True keyword arg pair if you want more verbiage ... rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project, debug=True, isolated_workspace=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) # 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)
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, apikey, workspace, project = rallyWorkset(options) #rally = Rally(server, user, password, apikey=apikey, workspace=workspace) rally = Rally(server, user, password, workspace=workspace, project=project) rally.enableLogging("rally.history.addtags") if len(args) < 2: print(USAGE) sys.exit(1) story_id = args.pop(0) tag_names = args[:] tags = [] story = rally.get('Story', fetch="FormattedID,Name,Description,Tags", query="FormattedID = %s" % story_id, server_ping=False, isolated_workspace=True, instance=True) response = rally.get('Tag', fetch="true", order="Name", server_ping=False, isolated_workspace=True) for tag in response: print("Workspace %s has tag: %-14.14s created on %s Name: %s" % \ (tag.Workspace.Name, tag.oid, tag.CreationDate[:-5].replace('T', ' '), tag.Name)) if tag.Name in tag_names: tags.append(tag) print("=====================================================") print(", ".join([tag.Name for tag in tags])) adds = rally.addCollectionItems(story, tags) print(adds) droppable_tags = [tag for tag in tags if tag.Name == VICTIM_TAG_NAME] print("dropping Tags %s ..." % ", ".join([tag.Name for tag in droppable_tags])) drops = rally.dropCollectionItems(story, droppable_tags) if drops.errors: print("Problem attempting to drop tags: %s" % drops.errors) sys.exit(2) story = rally.get('Story', fetch="FormattedID,Name,Description,Tags", query="FormattedID = %s" % story_id, server_ping=False, isolated_workspace=True, instance=True) #print(story.details()) print "story tags after deleting the '%s' Tag" % (droppable_tags[0].Name) story_tags = [str(tag.Name) for tag in story.Tags] print(story_tags)
def main(args): options = [opt for opt in args if opt.startswith('--')] args = [arg for arg in args if arg not in options] entity = args.pop(0) attributes = args server, user, password, apikey, workspace, project = rallyWorkset(options) print(" ".join(["|%s|" % item for item in [server, user, password, apikey, workspace, project]])) #rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project, server_ping=False) rally = Rally(server, user, password, apikey=apikey,server_ping=False) #rally.enableLogging('rally.hist.avl') # name of file you want the logging to go to target = entity if entity in ['Story', 'User Story', 'UserStory']: entity = "HierarchicalRequirement" target = entity mo = CAMEL_CASED_NAME_PATT.search(entity) if mo: txfm = re.sub(CAMEL_CASED_NAME_PATT, r'\1 \2', entity) print('transforming query target "%s" to "%s"' % (entity, txfm)) entity = txfm print("%s" % entity) response = rally.get('TypeDefinition', fetch="Name,Attributes", query='Name = "%s"' % entity) # could check for response.errors here... if response.errors: print("Errors: %s" % response.errors) if response.warnings: print("Warnings: %s" % response.warnings) td = response.next() std_attributes = sorted([attr for attr in td.Attributes if attr.ElementName[:2] != 'c_'], key=lambda x: x.ElementName) custom_attributes = sorted([attr for attr in td.Attributes if attr.ElementName[:2] == 'c_'], key=lambda x: x.ElementName) all_attributes = std_attributes + custom_attributes for attribute in all_attributes: attr_name = attribute.Name.replace(' ', '') if attributes and attr_name not in attributes: continue if attribute.AttributeType not in ['STATE', 'RATING', 'STRING', 'COLLECTION']: continue allowed_values = rally.getAllowedValues(target, attr_name) if allowed_values: print(" %-28.28s (%s)" % (attr_name, attribute.AttributeType)) for av in allowed_values: print(" |%s|" % av)
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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 %-36.36s |%s|" % (project.oid, project.Name, project.State) print ""
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, apikey, workspace, project = rallyWorkset(options) # print(" ".join(["|%s|" % item for item in [server, user, password, apikey[:8], workspace, project]])) # If you want to use BasicAuth, use the following form rally = Rally(server, user, password, workspace=workspace, project=project) # If you want to use API Key, you can use the following form # rally = Rally(server, apikey=apikey, workspace=workspace, project=project) # the following form of obtaining a Rally instance will use the apikey if it is present (non None) # otherwise it will use the user and password for BasicAuth # add in the debug=True keyword arg if you want more verbiage ... # rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project, # debug=True, server_ping=False, isolated_workspace=True) rally.enableLogging("fire.log") 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) # 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)
def get_rally_projects(config_file): logger.info("Begin method get_rally_projects") projects =None rally_input = [] input = "--config=" + config_file rally_input.append(input) server, username, password, apikey, workspace, project = rallyWorkset(rally_input) logger.info("Server: "+server+", username: "******", password: "******", apikey: "+apikey+", workspace: "+workspace+", project: "+project) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) projects = rally.getProjects(workspace) logger.info("Project List: "+str(len(projects))) logger.info("End method get_rally_projects") return rally, projects, workspace
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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)
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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("")
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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project) target = args.pop(0) fields = "FormattedID,State,Name,CreationDate,RevisionHistory,Revisions" criteria = "FormattedID = %s" % target defect = rally.get('Defect', fetch=fields, query=criteria, instance=True) print "%s %10.10s %-11s %s" % (defect.FormattedID, defect.CreationDate, defect.State, defect.Name) print "" for rev in reversed(defect.RevisionHistory.Revisions): print "%d) %-22.22s %-16.16s %s\n" % \ (rev.RevisionNumber, rev.CreationDate.replace('T', ' '), rev.User.DisplayName, rev.Description)
def main(args): options = [opt for opt in args if opt.startswith('--')] server, username, password, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace) else: rally = Rally(server, user=username, password=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)))
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("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 server, username, password, apikey, workspace, project = rallyWorkset(options) print(" ".join(["|%s|" % item for item in [server, username, password, apikey, workspace, project]])) try: rally = Rally(server, username, password, apikey=apikey, workspace=workspace, server_ping=False) except Exception as ex: errout(str(ex.args[0])) sys.exit(1) sub_name = rally.subscriptionName() print("Subscription Name: %s" % sub_name) wksp = rally.getWorkspace() print("Workspace Name: %s" % wksp.Name) print("Entity: %s" % target) print("-----------") print("Attributes:") print("-----------") typedef = rally.typedef(target) showAttributes(rally, target, typedef.Attributes) print("") print("-" * 64) print("") for ix, ancestor in enumerate(typedef.inheritanceChain()): print("%s %s" % (" " * (ix*4), ancestor))
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) server, username, password, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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)
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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("%-8.8s %-52.52s %s" % (defect.FormattedID, defect.Name, defect.State)) print("-----------------------------------------------------------------") print(response.resultCount, "qualifying defects")
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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)
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging("rally.history.showstories") fields = "FormattedID,Name,Iteration,Feature" #criterion = 'Iteration.Name contains "Iteration 7"' criterion = '((Iteration.Name contains "Iteration 6")OR(Iteration.Name contains "Iteration 7")) AND (Feature != null)' response = rally.get('HierarchicalRequirement', fetch=fields, query=criterion, order="FormattedID", pagesize=200, limit=400) for story in response: print "%-8.8s %-52.52s %s %s" % (story.FormattedID, story.Name, story.Iteration.Name, story.Feature.Name) print "-----------------------------------------------------------------" print response.resultCount, "qualifying stories"
def setupRally(): 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, apikey, workspace, project = rallyWorkset(options) if apikey: print("S: " + str(server) + " A: " + apikey + " W: " + workspace + " P: " + project) rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: print("S: " + str(server) + " U: " + user + " P: " + password + " W: " + workspace + " P: " + project) rally = Rally(server, user, password, workspace=workspace, project=project) rally.enableLogging('mypyral.log') return (rally)
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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, apikey=apikey, workspace=workspace) rally.enableLogging("rally.history.updtag") if len(args) != 2: print(USAGE) sys.exit(1) target_name, new_name = args[:2] target_oid = None response = rally.get('Tag', fetch="true", order="Name", server_ping=False, isolated_workspace=True) for tag in response: print("Workspace %s has tag: %-14.14s created on %s Name: %s" % \ (tag.Workspace.Name, tag.oid, tag.CreationDate[:-5].replace('T', ' '), tag.Name)) if tag.Name == target_name: target_oid = tag.oid if not target_oid: print("No Tag exists with a Name value of |%s|" % target_name) sys.exit(1) info = {"ObjectID": target_oid, "Name": new_name} print(info) print("attempting to update Tag with Name of '%s' to '%s' ..." % (target_name, new_name)) try: tag = rally.update('Tag', info) except RallyRESTAPIError, details: sys.stderr.write('ERROR: %s \n' % details) sys.exit(2)
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) != 2: errout('ERROR: You must supply an Artifact identifier and an attachment file name') errout(USAGE) sys.exit(1) target, attachment_file_name = args server, username, password, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging('rally.hist.creattach') # name of file you want logging to go to 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)
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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, username, password, apikey=apikey, workspace=workspace) wksp = rally.getWorkspace() print("Workspace: %s" % wksp.Name) print("=" * (len(wksp.Name) + 12)) print("") for project in PROJECTS: rally.setProject(project) print(" %s" % project) print(" %s" % ('-' * len(project))) print("") response = getSchedulableArtifacts(rally) showSchedulableArtifacts(response) print("") print("-" * 80) print("") print("%d items" % response.resultCount) print("")
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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, apikey=apikey, workspace=workspace) wksp = rally.getWorkspace() print "Workspace: %s" % wksp.Name print "=" * (len(wksp.Name) + 12) print "" for project in PROJECTS: rally.setProject(project) print " %s" % project print " %s" % ('-' * len(project)) print "" response = getSchedulableArtifacts(rally) showSchedulableArtifacts(response) print "" print "-" * 80 print "" print "%d items" % response.resultCount print ""
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) 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("")
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, username, password, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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 target_workspace = rally.getWorkspace() target_project = rally.getProject() info = {"FormattedID": taskID, "State": "In-Progress"} ## print info try: task = rally.update('Task', info) except RallyRESTAPIError, details: sys.stderr.write('ERROR: %s \n' % details) sys.exit(2)
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, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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)
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, apikey, workspace, project = rallyWorkset( options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging("rally.history.showstories") fields = "FormattedID,Name,Iteration,Feature" #criterion = 'Iteration.Name contains "Iteration 7"' criterion = '((Iteration.Name contains "Iteration 6")OR(Iteration.Name contains "Iteration 7")) AND (Feature != null)' response = rally.get('HierarchicalRequirement', fetch=fields, query=criterion, order="FormattedID", pagesize=200, limit=400) for story in response: print "%-8.8s %-52.52s %s %s" % (story.FormattedID, story.Name, story.Iteration.Name, story.Feature.Name) print "-----------------------------------------------------------------" print response.resultCount, "qualifying stories"
def main(args): # parse command line options # first Rally options that start with '--' options = [opt for opt in args if opt.startswith('--')] args = [arg for arg in args if arg not in options] server, username, password, apikey, workspace, project = rallyWorkset( options) query_criteria = '' try: opts, args = getopt.getopt(args, "e") except getopt.GetoptError: print 'espid.py [-e]' sys.exit(2) for opt,arg in opts: if opt == '-e': exceptionsOnly = True #print 'Reporting exceptions only' elif opt == '-q': query_criteria = arg # print " ".join(['%' % opt for opt in [server, username, password, # apikey, workspace, project]]) #print "%s %s %s %s %s" % (username, password, apikey, workspace, project) if apikey: #print "using apikey" rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: #print 'not using apikey' rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging('rally.hist.espid') # name of file for logging content if (query_criteria): response = rally.get('PortfolioItem/Feature', fetch=True, order='FeatureID', projectScopeUp = False, projectScopeDown = True, query=query_criteria) else: response = rally.get('PortfolioItem/Feature', fetch=True, order='FeatureID', projectScopeUp = False, projectScopeDown = True) print 'feature, espid feature, epic espid, epic, project' for f in response: #featureESPID = story.Feature.c_ESPID epic = '' epicESPID = '' feature = '' featureESPID = '' try: feature = f.FormattedID + ' ' + f.Name featureESPID = f.c_ESPID if str(featureESPID) == "None": #c_ESPID is type long featureESPID = ' ' try: epic = f.Parent.FormattedID + ' ' + f.Parent.Name epicESPID = f.Parent.c_ESPID if str(epicESPID) == "None": epicESPID = ' ' except AttributeError: epic = 'No Epic' epicESPID = ' ' except AttributeError: feature = 'No Feature' featureESPID = ' ' epic = 'No Epic' epicESPID = ' ' owner = '' try: owner = f.Owner.Name except AttributeError: owner = 'No Owner' if not exceptionsOnly or (exceptionsOnly and featureESPID != epicESPID): print '"%s",%s,%s,"%s",%s' % ( feature, featureESPID, epicESPID, epic, f.Project.Name )
import sys from pyral import Rally, rallyWorkset # useage python iteration-list.py --config=my.cfg StoryId 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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, workspace=workspace, project=project) rally.enableLogging('mypyral.log') # create query for story in rally.get('UserStory', query='FormattedID = ' + args[0]): iteration = story.Iteration for sty in rally.get('UserStory', query='Iteration.oid = ' + iteration.oid): print "%s %s" % (sty.FormattedID, sty.Name) print "" print "%s" % (sty.Description) print ""
import sys from pyral import Rally, rallyWorkset 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, apikey, workspace, project = rallyWorkset(options) rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project) rally.enableLogging('C:\\Users\\sg0303348\\Downloads\\mypyral.log')
def main(args): # parse command line options # first Rally options that start with '--' # see pyral documenation for use of config file and/or args for rally config options = [opt for opt in args if opt.startswith('--')] args = [arg for arg in args if arg not in options] server, username, password, apikey, workspace, project = rallyWorkset(options) exceptionsOnly = False try: opts, args = getopt.getopt(args, "ei:q:u") #print opts #print args except getopt.GetoptError: print 'initiative.py [-x]' sys.exit(2) for opt,arg in opts: if opt == '-e': exceptionsOnly = True elif opt == '-i': #just the iteration query_criteria = '(Iteration.Name contains "%s")' % arg elif opt == '-q': #complete query string query_criteria = arg elif opt == '-u': updateStory = True # print " ".join(['%' % opt for opt in [server, username, password, # apikey, workspace, project]]) #print "%s %s %s %s %s" % (username, password, apikey, workspace, project) if apikey: #print "using apikey" rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: #print 'not using apikey' rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging('rally.hist.espid') # name of file for logging content #print 'getting stories' response = rally.get('PortfolioItem/Initiative', fetch=True, query=query_criteria) #print 'story,owner,project,planEstTot,taskEstTot,iteration,iteration start,iteration end,feature,f_espid,epic,e_espid,initiative,i_InvestmentCategory' for record in response: #f_cESPID = story.Feature.c_ESPID initiative = '' i_InvestmentCategory = '' i_cStategicInvestmentType = '' i_cStategicPillar = '' i_cTier = '' owner = '' try: owner = record.Owner.Name except AttributeError: owner = 'No Owner' print record.FormattedID print record.Name print record.c_StrategicInvestmentType print record.c_StrategicPillar print record.c_Tier
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, username, password, apikey, workspace, project = rallyWorkset(options) if apikey: rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: rally = Rally(server, user=username, password=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_target = '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 as details: sys.stderr.write('ERROR: %s \n' % details) sys.exit(2) print("Task updated") print("ObjectID: %s FormattedID: %s" % (task.oid, task.FormattedID))
def main(args): # parse command line options # first Rally options that start with '--' # see pyral documenation for use of config file and/or args for rally config options = [opt for opt in args if opt.startswith('--')] args = [arg for arg in args if arg not in options] server, username, password, apikey, workspace, project = rallyWorkset(options) exceptionsOnly = False try: opts, args = getopt.getopt(args, "ei:q:u") #print opts #print args except getopt.GetoptError: print 'espid.py [-x]' sys.exit(2) for opt,arg in opts: if opt == '-e': exceptionsOnly = True elif opt == '-i': #just the iteration query_criteria = '(Iteration.Name contains "%s")' % arg elif opt == '-q': #complete query string query_criteria = arg elif opt == '-u': updateStory = True # print " ".join(['%' % opt for opt in [server, username, password, # apikey, workspace, project]]) #print "%s %s %s %s %s" % (username, password, apikey, workspace, project) if apikey: #print "using apikey" rally = Rally(server, apikey=apikey, workspace=workspace, project=project) else: #print 'not using apikey' rally = Rally(server, user=username, password=password, workspace=workspace, project=project) rally.enableLogging('rally.hist.espid') # name of file for logging content #print 'getting stories' stories_response = rally.get('UserStory', fetch=True, query=query_criteria, order='Feature') print 'story~owner~project~planEstTot~taskEstTot~iteration~iteration start~iteration end~feature~f_espid~epic~e_espid~initiative~i_InvestmentCategory~i_pillar~i_tier' for story in stories_response: #f_cESPID = story.Feature.c_ESPID initiative = '' i_InvestmentCategory = '' i_cStategicInvestmentType = '' i_cStategicPillar = '' i_cTier = '' epic = '' e_InvestmentCategory = '' e_cESPID = '' e_cStategicInvestmentType = '' e_Tier = '' feature = '' f_InvestmentCategory = '' f_cESPID = '' f_Tier = '' try: feature = story.Feature.FormattedID + ' ' + story.Feature.Name f_cESPID = story.Feature.c_ESPID if str(f_cESPID) == "None": #c_ESPID is type long f_cESPID = ' ' try: epic = story.Feature.Parent.FormattedID + ' ' + story.Feature.Parent.Name #e_cStategicInvestmentType = story.Feature.Parent.c_StategicInvestmentType.Name e_cESPID = story.Feature.Parent.c_ESPID if str(e_cESPID) == "None": e_cStategicInvestmentType = ' ' e_cESPID = ' ' try: initiative = story.Feature.Parent.Parent.FormattedID + ' ' + story.Feature.Parent.Parent.Name i_cStategicInvestmentType = story.Feature.Parent.Parent.c_StrategicInvestmentType i_cStategicPillar = story.Feature.Parent.Parent.c_StrategicPillar i_cTier = story.Feature.Parent.Parent.c_Tier except AttributeError: initiative = 'no initiative' i_cStategicInvestmentType = '' i_cStategicPillar = '' i_cTier = '' i_cStategicInvestmentType = ' ' except AttributeError: epic = 'No Epic' e_cESPID = ' ' except AttributeError: feature = 'No Feature' f_cESPID = ' ' epic = 'No Epic' e_cESPID = ' ' owner = '' try: owner = story.Owner.Name except AttributeError: owner = 'No Owner' if not exceptionsOnly or (exceptionsOnly and f_cESPID != e_cESPID): print '"%s %s"~%s~%s~%s~%s~%s~%s~%s~"%s"~%s~"%s"~%s~"%s"~%s~ %s~%s' % ( story.FormattedID, story.Name, owner, story.Project.Name, story.PlanEstimate, story.TaskEstimateTotal, story.Iteration.Name, story.Iteration.StartDate, story.Iteration.EndDate, feature, f_cESPID, epic, e_cESPID, initiative, i_cStategicInvestmentType, i_cStategicPillar, i_cTier )