def get_stories(projectIds): session = connect() stories = {} querystring = '(' for projId in projectIds: if len(querystring) > 1: querystring += ' or ' if len(projectIds) > 1: querystring += '(' querystring += 'Project = https://' + settings.RALLY_SERVER + '/slm/webservice/' + settings.RALLY_REST_VERSION + '/project/' + projId if len(projectIds) > 1: querystring += ')' querystring += ')' print 'QueryString is ' + querystring start = 1 pagesize = 200 lastPage = False while not (lastPage): url = 'https://' + settings.RALLY_SERVER + '/slm/webservice/' + settings.RALLY_REST_VERSION + '/hierarchicalrequirement.js?query=' + urllib.quote( querystring) + '&fetch=true&start=' + str( start) + '&pagesize=' + str(pagesize) print 'Fetching url ' + url resp = session.get(url) print 'Got response ' + str(resp.status_code) if resp.status_code != 200: raise Exception('Error returned from Rally: ' + resp.text) queryresult = json.loads(resp.text) for result in queryresult['QueryResult']['Results']: story = Story() story.rally_id = result['FormattedID'] story.name = result['Name'] if result['Iteration']: story.sprint = result['Iteration']['_refObjectName'] stories[story.rally_id] = story print 'results: ' + str( queryresult['QueryResult']['TotalResultCount']) + ' start ' + str( start) + ' for pagesize ' + str(pagesize) if queryresult['QueryResult']['TotalResultCount'] <= start + pagesize: lastPage = True start += pagesize return stories
def get_stories(projectIds): session = connect() stories = {} querystring = '(' for projId in projectIds: if len(querystring) > 1: querystring += ' or ' if len(projectIds) > 1: querystring += '(' querystring += 'Project = https://' + settings.RALLY_SERVER + '/slm/webservice/' + settings.RALLY_REST_VERSION + '/project/' + projId if len(projectIds) > 1: querystring += ')' querystring += ')' print 'QueryString is ' + querystring start = 1 pagesize = 200 lastPage = False while not(lastPage): url = 'https://' + settings.RALLY_SERVER + '/slm/webservice/' + settings.RALLY_REST_VERSION + '/hierarchicalrequirement.js?query=' + urllib.quote(querystring) + '&fetch=true&start=' + str(start) + '&pagesize=' + str(pagesize) print 'Fetching url ' + url resp = session.get(url) print 'Got response ' + str(resp.status_code) if resp.status_code != 200: raise Exception('Error returned from Rally: ' + resp.text) queryresult = json.loads(resp.text) for result in queryresult['QueryResult']['Results']: story = Story() story.rally_id = result['FormattedID'] story.name = result['Name'] if result['Iteration']: story.sprint = result['Iteration']['_refObjectName'] stories[story.rally_id] = story print 'results: ' + str(queryresult['QueryResult']['TotalResultCount']) + ' start ' + str(start) + ' for pagesize ' + str(pagesize) if queryresult['QueryResult']['TotalResultCount'] <= start + pagesize: lastPage = True start += pagesize return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not (lastPage): storyurl = agileurl + apiurl + 'projects/' + projId + '/stories?' + get_page_query_params( page, pagesize) logger.debug('Retrieving Stories from URL: ' + storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d' % count for result in story_list: #print result phase = result[u'phase'] ignorestates = [ u'Backlog', u'Ready', u'Archive', u'Release Candidate / Production' ] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl + 'project/' + projId + '/story/%d' % result[ u'id'] try: story.sprint = '%s - %s' % (projId, result[u'deadline']) #story.release_date = result[u'deadline'] except: story.sprint = '%s' % projId logger.debug('no deadline for story %d' % story.rally_id) stories[story.rally_id] = story if count == 0: lastPage = True page += 1 return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not (lastPage): storyurl = agileurl + apiurl + 'projects/' + projId + '/stories?' + get_page_query_params( page, pagesize) logger.debug('Retrieving Stories from URL: ' + storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d' % count for result in story_list: #print result phase = result[u'phase'] ignorestates = [u'Backlog'] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl + 'project/' + projId + '/story/%d' % result[ u'id'] project = result[u'project'] project_name = project[u'name'] projshort_name = '' try: projshort_name = (re.search(r'\(.*?\)', project_name)).group() except: #expected the project name to have a short name in () #this will cut the name down to 10 characters and append ERRNOPAREN projshort_name = '%s-%s' % (project_name[0:10], '(ERRNOPAREN)') story.sprint = '%s - %s' % (projId, projshort_name) storykey = '%s-%s' % (story.rally_id, story.sprint) #print 'generated key for stories list - %s' % storykey stories[storykey] = story if count == 0: lastPage = True page += 1 return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not(lastPage): storyurl = agileurl+apiurl+'projects/'+ projId +'/stories?'+ get_page_query_params(page, pagesize) logger.debug('Retrieving Stories from URL: '+storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d'%count for result in story_list: #print result phase = result[u'phase'] ignorestates = [u'Backlog'] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl+'project/'+ projId +'/story/%d'%result[u'id'] project = result[u'project'] project_name = project[u'name'] projshort_name = '' try: projshort_name = (re.search( r'\(.*?\)', project_name)).group() except: #expected the project name to have a short name in () #this will cut the name down to 10 characters and append ERRNOPAREN projshort_name = '%s-%s' % (project_name[0:10],'(ERRNOPAREN)') story.sprint = '%s - %s' % (projId, projshort_name) storykey = '%s-%s' % (story.rally_id, story.sprint) #print 'generated key for stories list - %s' % storykey stories[storykey] = story if count == 0: lastPage = True page += 1 return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not(lastPage): storyurl = agileurl+apiurl+'projects/'+ projId +'/stories?'+ get_page_query_params(page, pagesize) logger.debug('Retrieving Stories from URL: '+storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d'%count for result in story_list: #print result phase = result[u'phase'] ignorestates = [u'Backlog', u'Ready', u'Archive', u'Release Candidate / Production'] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl+'project/'+ projId +'/story/%d'%result[u'id'] try: story.sprint = '%s - %s' % (projId, result[u'deadline']) #story.release_date = result[u'deadline'] except: story.sprint = '%s'%projId logger.debug('no deadline for story %d'%story.rally_id) stories[story.rally_id] = story if count == 0: lastPage = True page += 1 return stories
def addtostory(request): log = logging.getLogger("user") results = {"success": False} if request.method == u"GET": story = None try: storyId = request.GET["storyId"] if storyId == "null": storyId = "" storyName = request.GET["storyName"] storyRallyId = request.GET["storyRallyId"] storyURL = request.GET["storyURL"] if len(storyId) > 0 or len(storyRallyId) > 0: if len(storyId) > 0: try: story = Story.objects.get(id=storyId) except ObjectDoesNotExist: pass if not story and len(storyRallyId) > 0: try: story = Story.objects.get(rally_id=storyRallyId) except ObjectDoesNotExist: pass if not story: story = Story() if len(storyRallyId) > 0: story.rally_id = storyRallyId story.url = "https://rally1.rallydev.com/slm/detail/" + story.rally_id if len(storyURL) > 0: story.url = storyURL if len(storyName) > 0: story.name = storyName story.save() objectIds = request.GET.getlist("itemid") objects = DeployableObject.objects.filter(id__in=objectIds) for object in objects: if story: object.pending_stories.add(story) object.release_status = "p" object.save() transIds = request.GET.getlist("transid") translations = DeployableTranslation.objects.filter(id__in=transIds) for translation in translations: if story: translation.pending_stories.add(story) translation.release_status = "p" translation.save() results = {"success": True} except Exception as ex: tb = traceback.format_exc() results = {"success": False, "error": "ERROR: " + tb} json = simplejson.dumps(results) return HttpResponse(json, mimetype="application/json")
def addtostory(request): log = logging.getLogger('user') results = {'success':False} if request.method == u'GET': story = None try: storyId = request.GET['storyId'] if (storyId == 'null'): storyId = '' storyName = request.GET['storyName'] storyRallyId = request.GET['storyRallyId'] storyURL = request.GET['storyURL'] if len(storyId) > 0 or len(storyRallyId) > 0: if len(storyId) > 0: try: story = Story.objects.get(id=storyId) except ObjectDoesNotExist: pass if not story and len(storyRallyId) > 0: try: story = Story.objects.get(rally_id=storyRallyId) except ObjectDoesNotExist: pass if not story: story = Story() if len(storyRallyId) > 0: story.rally_id = storyRallyId story.url = "https://rally1.rallydev.com/slm/detail/" + story.rally_id if len(storyURL) > 0: story.url = storyURL if len(storyName) > 0: story.name = storyName story.save() objectIds = request.GET.getlist('itemid'); objects = DeployableObject.objects.filter(id__in=objectIds) for object in objects: if story: object.pending_stories.add(story) object.release_status = 'p' object.save() transIds = request.GET.getlist('transid'); translations = DeployableTranslation.objects.filter(id__in=transIds) for translation in translations: if story: translation.pending_stories.add(story) translation.release_status = 'p' translation.save() results = {'success':True} except Exception as ex: tb = traceback.format_exc() results = {'success':False, 'error':'ERROR: ' + tb} json = simplejson.dumps(results) return HttpResponse(json, mimetype='application/json')
def get_stories(projectIds): urllib2 = connect() stories = {} for projId in projectIds: url = 'https://' + settings.RALLY_SERVER + '/slm/webservice/' + settings.RALLY_REST_VERSION + '/project/' + projId + '.js' logger.debug('Fetching url ' + url) pcprojjson = urllib2.urlopen(url).read() pcproj = json.loads(pcprojjson) logger.debug('Processing project ' + pcproj['Project']['_refObjectName']) pcproj['Project']['Iterations'] sprint_data = {} sprint_names = {} sprints = [] for iteration in pcproj['Project']['Iterations']: sprdet = urllib2.urlopen(iteration['_ref']).read() sprint = json.loads(sprdet) # 2010-07-12T00:00:00.000Z sprintName = iteration['_refObjectName'] startDate = sprint['Iteration']['StartDate'][0:10] logger.debug('Looking at sprint ' + sprintName) logger.debug('Date is ' + startDate) sprint_data[startDate + '_' + sprintName] = sprint sprint_names[startDate + '_' + sprintName] = sprintName sprints.append(startDate + '_' + sprintName) sprints.sort() for sprint_key in sprints: logger.debug('Processing ' + sprint_key) sprint = sprint_data[sprint_key] sprintName = sprint_names[sprint_key] hist = urllib2.urlopen(sprint['Iteration']['RevisionHistory']['_ref']).read() history = json.loads(hist) revisions = list() for rev in history['RevisionHistory']['Revisions']: revisions.append(rev) revisions.reverse() for rev in revisions: if rev['Description'].startswith('Scheduled ') or rev['Description'].startswith('Unscheduled '): ral_id = rev['Description'].split('[')[1].split(']')[0].partition(':')[0] ral_name = rev['Description'][rev['Description'].find(':') + 2:150] if ral_name.endswith(']'): ral_name = ral_name[0:ral_name.rfind(']')] if rev['Description'].startswith('Scheduled '): logger.debug('Add [' + ral_id + '] ' + ral_name) if ral_id not in stories: story = Story() story.rally_id = ral_id story.name = ral_name story.sprint = sprintName stories[ral_id] = story else: story = stories[ral_id] story.sprint = sprintName if rev['Description'].startswith('Unscheduled '): logger.debug('Remove [' + ral_id + '] ' + ral_name) if ral_id in stories: story = stories[ral_id] if story.sprint == sprintName: story.sprint = '' return stories
def get_stories(projectIds): urllib2 = connect() stories = {} for projId in projectIds: url = 'https://' + settings.RALLY_SERVER + '/slm/webservice/' + settings.RALLY_REST_VERSION + '/project/' + projId + '.js' logger.debug('Fetching url ' + url) pcprojjson = urllib2.urlopen(url).read() pcproj = json.loads(pcprojjson) logger.debug('Processing project ' + pcproj['Project']['_refObjectName']) pcproj['Project']['Iterations'] sprint_data = {} sprint_names = {} sprints = [] for iteration in pcproj['Project']['Iterations']: sprdet = urllib2.urlopen(iteration['_ref']).read() sprint = json.loads(sprdet) # 2010-07-12T00:00:00.000Z sprintName = iteration['_refObjectName'] startDate = sprint['Iteration']['StartDate'][0:10] logger.debug('Looking at sprint ' + sprintName) logger.debug('Date is ' + startDate) sprint_data[startDate + '_' + sprintName] = sprint sprint_names[startDate + '_' + sprintName] = sprintName sprints.append(startDate + '_' + sprintName) sprints.sort() for sprint_key in sprints: logger.debug('Processing ' + sprint_key) sprint = sprint_data[sprint_key] sprintName = sprint_names[sprint_key] hist = urllib2.urlopen( sprint['Iteration']['RevisionHistory']['_ref']).read() history = json.loads(hist) revisions = list() for rev in history['RevisionHistory']['Revisions']: revisions.append(rev) revisions.reverse() for rev in revisions: if rev['Description'].startswith('Scheduled ') or rev[ 'Description'].startswith('Unscheduled '): ral_id = rev['Description'].split('[')[1].split( ']')[0].partition(':')[0] ral_name = rev['Description'][rev['Description']. find(':') + 2:150] if ral_name.endswith(']'): ral_name = ral_name[0:ral_name.rfind(']')] if rev['Description'].startswith('Scheduled '): logger.debug('Add [' + ral_id + '] ' + ral_name) if ral_id not in stories: story = Story() story.rally_id = ral_id story.name = ral_name story.sprint = sprintName stories[ral_id] = story else: story = stories[ral_id] story.sprint = sprintName if rev['Description'].startswith('Unscheduled '): logger.debug('Remove [' + ral_id + '] ' + ral_name) if ral_id in stories: story = stories[ral_id] if story.sprint == sprintName: story.sprint = '' return stories