Beispiel #1
0
def get_new_tbpl_url(new_revision, new_branch, alert_id):
    '''
    To generate new tbpl url when branch is changed
    '''
    db = create_db_connnection()
    cursor = db.cursor()
    sql = "select test, platform from alerts where id=%s" % alert_id
    cursor.execute(sql)
    search_results = cursor.fetchall()
    search_results = search_results[0]
    test = search_results[0]
    platform = search_results[1]
    record = Record(test, platform, new_branch, new_revision)
    link = build_tbpl_link(record)
    cursor.close()
    db.close()

    return link
Beispiel #2
0
def get_new_tbpl_url(new_revision, new_branch, alert_id):
    '''
    To generate new tbpl url when branch is changed
    '''
    db = create_db_connnection()
    cursor = db.cursor()
    sql = "select test, platform from alerts where id=%s" %alert_id
    cursor.execute(sql)
    search_results = cursor.fetchall()
    search_results = search_results[0]
    test = search_results[0]
    platform = search_results[1]
    record = Record(test, platform, new_branch, new_revision)
    link = build_tbpl_link(record)
    cursor.close()
    db.close()

    return link 
Beispiel #3
0
def run_updatekeyrev_data():
    '''
    To change keyrevision of a particular alert

    '''
    retVal = {}
    data = request.form
    alert_details = get_details_from_id(data['id'])
    record = Record(alert_details['test'], alert_details['platform'], alert_details['branch'], data['revision'])
    new_tbplurl = build_tbpl_link(record)
    sql = "update alerts set keyrevision='%s', tbplurl='%s' where id=%s;" % (data['revision'], new_tbplurl, data['id'])

    db = create_db_connnection()
    cursor = db.cursor()
    cursor.execute(sql)
    alerts = cursor.fetchall()

    return jsonify(**retVal)
Beispiel #4
0
def run_updatekeyrev_data():
    '''
    To change keyrevision of a particular alert

    '''
    retVal = {}
    data = request.form
    alert_details = get_details_from_id(data['id'])
    record = Record(alert_details['test'], alert_details['platform'], alert_details['branch'], data['revision'])
    new_tbplurl = build_tbpl_link(record)
    sql = "update alerts set keyrevision='%s', tbplurl='%s' where id=%s;" % (data['revision'], new_tbplurl, data['id'])

    db = create_db_connnection()
    cursor = db.cursor()
    cursor.execute(sql)
    alerts = cursor.fetchall()

    return jsonify(**retVal)
Beispiel #5
0
def parse_mailbox():
    """Main routine"""
    mbox = mailbox.MH(settings.MAILDIR)

    read = set(mbox.get_sequences().get('read', ''))
    unread = set(mbox.keys()) - read

    logger.info('Parsing mailbox. Got %d unread messages' % len(unread))

    for msg_id in unread:
        record = parse_message(mbox[msg_id])

        if not record:
            logger.info('Message can not be parsed')
            continue

        if record.push_date >= two_weeks:
            csets = get_revisions(record.changeset)
        else:
            csets = set()

        check_for_backout(record)
        merged = is_merged(record, csets)
        duplicate = check_for_duplicate(record)
        link = build_tbpl_link(record)

        update_database(record, merged, link, csets)
        #TODO: JMAHER: I am not sure how to handle this duplicate code, it needs to be reworked
        duplicate = check_for_duplicate(record)
        if merged:
            mark_merged(duplicate, merged)
        add_tbpl_url(duplicate, link)

    all_read = unread | read
    mbox.set_sequences({'read': all_read})

    logger.info('DONE')