示例#1
0
def get_ship_bug():
    """
    get ship bug
    """
    with open('README', 'r') as file_handle:
        content = file_handle.read()
        readme_bug = re.findall(README_PATTERN, content)
    logger.info(RFD_README.format(readme_bug))
    return readme_bug
示例#2
0
def is_duplicate(check_list, msg, list_tpye):
    """
    check whether duplicate in check_list
    """
    index = None
    dup = [{item:count} for item, count in \
          collections.Counter(check_list).items() if count > 1]
    if dup:
        for index, _ in enumerate(dup):
            bug = int(dup[index].keys()[0])
            bug_count = dup[index].values()[0]
            logger.info(CHK_DUP.format(bug, bug_count, list_tpye))
            msg += CHK_DUP.format(bug, bug_count, list_tpye)
        return True, msg
    return False, msg
示例#3
0
def get_rfd_list(fed_list):
    """
    get rfd list
    """
    rfd_list = list()
    fed_list = map(int, fed_list)
    for fed in fed_list:
        rfd_num = ''
        fix_where = requests.get(ALL_API.format(fed))
        soup = BeautifulSoup(fix_where.text, 'html.parser')
        rfd = soup.find_all('td', limit=2)
        if rfd:
            rfd_num = re.findall(RFD_PATTERN,
                                 rfd[0].get_text().encode('utf-8'))
        rfd_list.append(rfd_num[0])
    logger.info(RFD_PATCH.format(rfd_list))
    return rfd_list
示例#4
0
def get_fed_list(job):
    """
    get fed list
    """
    # get fed from patch depend on, and convert from int to string
    bug_api = BugHandler(BZ_URL, SVC_USER, SVC_PSWD)
    fed_list = map(str, bug_api.get_depends(job.bug))

    # get fed from patch comment
    all_comment = list()
    comment_num = None
    match_comment = ''
    fed_comment = list()
    try:
        all_comment = bug_api.get_comments(job.bug)
    except Exception as error:
        logger.info(FED_ERR.format(error))
    for index, comment_text in enumerate(all_comment):
        if re.findall(CONTENT_PATTERN, comment_text['text']):
            comment_num = index
            logger.info(CONTENT_ID.format(index))
    if comment_num:
        match_comment = all_comment[comment_num]['text']

    fed_comment = re.findall(FED_PATTERN, match_comment)
    logger.info(FED_LOG.format(fed_list, comment_num, fed_comment))
    return fed_list, fed_comment
示例#5
0
def cmp_rfd_ship(job, before=None, after=None, label=None, succ=None):
    """
    Compare RFD between bugzilla and readme
    """
    fail_result = False
    msg = 'RFD_Depend | RFD_Readme\n'
    logger.info("\n RFD_Depend | RFD_Readme")
    rfd_list = set(before) if isinstance(before, list) else before
    ship_bug = set(after) if isinstance(after, list) else after
    for rfd in rfd_list:
        if rfd in ship_bug:
            msg += "%s = %s\n" % (rfd, rfd)
            logger.info("%s = %s" % (rfd, rfd))
        else:
            msg += RFD_CMP1.format(rfd)
            fail_result = True
            logger.info(RFD_CMP1.format(rfd))
    for bug in ship_bug:
        if bug not in rfd_list:
            msg += RFD_CMP2.format(bug)
            fail_result = True
            logger.info(RFD_CMP2.format(bug))
    job.manifest.add_report(label, succ, msg, failed=fail_result)
    return (fail_result, msg)
示例#6
0
def cmp_feds(job, before=None, after=None, label=None, succ=None):
    """
    Compare FED between depends-on and comment
    """
    fail_result = False
    msg = 'FED_Depends | FED_Comment\n'
    logger.info("\n FED_Depends | FED_Comment")
    fed_list = set(before) if isinstance(before, list) else before
    fed_comment = set(after) if isinstance(after, list) else after
    for fed in fed_list:
        if fed in fed_comment:
            msg += "%s = %s\n" % (fed, fed)
            logger.info("%s = %s" % (fed, fed))
        else:
            msg += FED_CMP1.format(fed)
            fail_result = True
            logger.info(FED_CMP1.format(fed))
    for fed1 in fed_comment:
        if fed1 not in fed_list:
            msg += FED_CMP2.format(fed1)
            fail_result = True
            logger.info(FED_CMP2.format(fed1))
    job.manifest.add_report(label, succ, msg, failed=fail_result)
    return (fail_result, msg)