sys.exit() # Run the process for all the projects total_records_fetched = 0 for project_name in PROJECTS: rally.setProject(project_name) stat = 'Staging process started for project - {}'.format(project_name) logging.info(stat) c_log.callproc( 'BMR_LOG.INSERT_PROCESS_RUN_LOG_DTL', (l_run_id, info, stag + ' - Project : ' + project_name, stat)) response_total = rally.get(entity_type, fetch='ObjectID', query=query, projectScopeDown=True, limit=500, stream=True) query_errors = response_total.errors if not query_errors: try: query_result = response_total.content['QueryResult'] total = query_result['TotalResultCount'] total_records_fetched += total if total == 0: continue else: stat = 'API response iterator fetch complete for entity - {} and fetch_query - {}'.format(
(l_run_id, info, stag + ' - Active Artifacts END', stat)) except: stat = "Active artifacts fetch failed. Check previous errors/log file" logging.exception(stat) c_log.callproc('BMR_LOG.INSERT_PROCESS_RUN_LOG_DTL', (l_run_id, err, stag + ' - Active Artifacts', stat)) c_log.callproc('BMR_LOG.UPDATE_PROCESS_RUN_DTL', (l_run_id, 'F')) c_log.close() c1.close() conn.close() hdlr.close() sys.exit() response = rally.get(entity_type, fetch=True, query=query, projectScopeDown=True, limit=500) query_errors = response.errors total = response.content['QueryResult']['TotalResultCount'] stat = 'Total records to be fetched - {}'.format(total) logging.info(stat) c_log.callproc('BMR_LOG.INSERT_PROCESS_RUN_LOG_DTL', (l_run_id, info, stag, stat)) if not query_errors and total > 0: stat = 'API response iterator fetch complete for entity - {} and fetch_query - {}'.format( entity_type, query) logging.info(stat)