示例#1
0
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()
示例#2
0
def handle_pending_mozreview_updates(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})

    bugzilla_auth = mozreview.instantiate_authentication()

    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(
                bugzilla_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
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
示例#4
0
def push_to_try(update_id, transplant_id, request, data):
    """ Return update_id if update was successful, or False if it failed"""
        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:
                return update_id
            else:
                logger.info('failed: %s - %s' % (status_code, text))
                return False

        else:
            return update_id