def handle_pending_test_results(logger, dbconn): """Start the tests, if source branch isn't try""" cursor = dbconn.cursor() query = """ select MozreviewUpdate.id,transplant_id,request,data from MozreviewUpdate inner join Transplant on (Transplant.id = MozreviewUpdate.transplant_id) limit %(limit)s """ cursor.execute(query, {'limit': MOZREVIEW_COMMENT_LIMIT}) mozreview_auth = mozreview.read_credentials() updated = [] all_posted = True for row in cursor.fetchall(): update_id, transplant_id, request, data = row result = push_to_try(update_id, transplant_id, request, data) if result == False: # failed to post all_posted = False else: updated.append(result) # push_to_try returns update_id if updated: query = """ delete from MozreviewUpdate where id=%s """ cursor.executemany(query, updated) dbconn.commit() return all_posted
def handle_pending_mozreview_updates(logger, dbconn): """Attempt to post updates to mozreview""" cursor = dbconn.cursor() query = """ select request_id,pingback_url,data from MozreviewUpdate limit %(limit)s """ cursor.execute(query, {'limit': MOZREVIEW_COMMENT_LIMIT}) mozreview_auth = mozreview.read_credentials() updated = [] for row in cursor.fetchall(): request_id, pingback_url, data = row logger.info('trying to post mozreview update to: %s for request: %s' % (pingback_url, request_id)) status_code, text = mozreview.update_review(mozreview_auth, pingback_url, data) if status_code == 200: updated.append([request_id]) else: logger.info('failed: %s - %s' % (status_code, text)) if updated: query = """ delete from MozreviewUpdate where request_id=%s """ cursor.executemany(query, updated) dbconn.commit()
def handle_pending_mozreview_updates(logger, dbconn): """Attempt to post updates to mozreview""" cursor = dbconn.cursor() query = """ select MozreviewUpdate.id,transplant_id,request,data from MozreviewUpdate inner join Transplant on (Transplant.id = MozreviewUpdate.transplant_id) limit %(limit)s """ cursor.execute(query, {'limit': MOZREVIEW_COMMENT_LIMIT}) mozreview_auth = mozreview.read_credentials() updated = [] all_posted = True for row in cursor.fetchall(): update_id, transplant_id, request, data = row pingback_url = request.get('pingback_url') logger.info('trying to post mozreview update to: %s for request: %s' % (pingback_url, transplant_id)) # We allow empty pingback_urls as they make testing easier. We can # always check the logs for misconfigured pingback_urls. if pingback_url: status_code, text = mozreview.update_review(mozreview_auth, pingback_url, data) if status_code == 200: updated.append([update_id]) else: logger.info('failed: %s - %s' % (status_code, text)) all_posted = False break else: updated.append([update_id]) if updated: query = """ delete from MozreviewUpdate where id=%s """ cursor.executemany(query, updated) dbconn.commit() return all_posted