Beispiel #1
0
def main():
    parser = argparse.ArgumentParser(description='pull all bugs from a '
                                     'launchpad project')

    args = parser.parse_args()

    #    launchpad = Launchpad.login_anonymously('OpenStack Infra Bugday',
    #                                            'production',
    #                                            LPCACHEDIR)
    #    project = launchpad.projects[LPPROJECT]
    bz = Bugzilla(url=BZURL)

    counter = 0

    nova_status = "Unknown"

    f = open('bugs-refresh.json', 'w')
    f.write('{"date": "%s", "bugs": [' % datetime.datetime.now())

    #    for task in project.searchTasks(status=LPSTATUS, importance=LPIMPORTANCE,
    #                                    omit_duplicates=True,
    #                                    order_by='-importance'):
    bzq = bz.build_query(product=LPPROJECT, status=BZSTATUS)
    #bzq = bz.build_query(bug_id='1154635')
    bugs = bz.query(bzq)
    for task in bugs:
        #if counter == 300:
        #    break
        #        bug = launchpad.load(task.bug_link)
        #
        #        nova_status = 'Unknown'
        #        nova_owner = 'Unknown'
        #
        #        for task in bug.bug_tasks:
        #            if task.bug_target_name == LPPROJECT:
        #                nova_status = task.status
        #                nova_owner = task.assignee
        #                break
        try:
            if counter != 0:
                bug_data = ','
            else:
                bug_data = u""
            title = task.summary.replace('"', "'")
            title = title.replace("\n", "")
            title = title.replace("\t", "")
            bug_data += (
                '{"index": %d, "id": %d, "importance": "%s", '
                '"status": "%s", '
                '"owner": "%s", '
                '"title": "%s", '
                '"link": "%s"' %
                (counter, task.id, getBugPriority(task), getBugStatus(task),
                 task.assigned_to, title, task.weburl))

        except (TypeError, UnicodeEncodeError):
            # TODO: fix this
            print 'Error on bug %d', task.id
            counter += 1
            continue

        age = delta(
            datetime.datetime.strptime("%s" % task.creation_time,
                                       "%Y%m%dT%H:%M:%S"))
        updated = delta(
            datetime.datetime.strptime("%s" % task.last_change_time,
                                       "%Y%m%dT%H:%M:%S"))
        stale = False
        if updated > 30 and age > 30:
            if task.status == 'ASSIGNED':
                stale = True
        bug_data += (',"age": %d, "update": %d, "stale": %d, '
                     '"never_touched": %d' %
                     (age, updated, 1 if stale else 0,
                      1 if len(task.comments) == 1 else 0))

        i = 0
        bug_data += (',"projects": [')
        bug_data += '{"target": "%s", "status": "%s"}' % (task.target_release,
                                                          task.status)
        bug_data += ('] ,"reviews": [')

        i = 0
        for review in get_reviews_from_bug(task):
            review_status = get_review_status(review)
            if i != 0:
                bug_data += (",")
            i += 1
            review_status = review_status.replace("\n", "")
            bug_data += ('{"review": '
                         '"%s/%s",'
                         '"status": "%s"}' %
                         (GERRIT_URL, review, review_status))
        bug_data += (']}')

        try:
            if counter == 0:
                json.loads(bug_data)
            else:
                json.loads(bug_data[1:])
            f.write(bug_data)
        except (ValueError, UnicodeEncodeError), e:
            print e, '[Bug: %s]' % task.id

        counter += 1
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser(description='pull all bugs from a '
                                     'bugzilla project')

    args = parser.parse_args()

    bz = Bugzilla(url=BZURL)

    counter = 0

    f = open('bugs-refresh.json', 'w')
    f.write('{"date": "%s", "bugs": [' % datetime.datetime.now())

    bzq = bz.build_query(product=LPPROJECT, status=BZSTATUS)
    bugs = bz.query(bzq)
    for task in bugs:
        try:
            if counter != 0:
                bug_data = ','
            else:
                bug_data = u""
            title = task.summary.replace('"', "'")
            title = title.replace("\n", "")
            title = title.replace("\t", "")
            bug_data += (
                '{"index": %d, "id": %d, "importance": "%s", '
                '"status": "%s", '
                '"owner": "%s", '
                '"title": "%s", '
                '"link": "%s", '
                '"component": "%s"' %
                (counter, task.id, getBugPriority(task), getBugStatus(task),
                 task.assigned_to, title.encode(
                     'ascii', 'ignore'), task.weburl, task.component))

        except (TypeError, UnicodeEncodeError):
            # TODO: fix this
            print 'Error on bug %d', task.id
            counter += 1
            continue

        age = delta(
            datetime.datetime.strptime("%s" % task.creation_time,
                                       "%Y%m%dT%H:%M:%S"))
        updated = delta(
            datetime.datetime.strptime("%s" % task.last_change_time,
                                       "%Y%m%dT%H:%M:%S"))
        stale = False
        if updated > 30 and age > 30:
            if task.status == 'ASSIGNED':
                stale = True
        bug_data += (',"age": %d, "update": %d, "stale": %d, '
                     '"never_touched": %d' %
                     (age, updated, 1 if stale else 0,
                      1 if len(task.comments) == 1 else 0))

        i = 0
        bug_data += (',"projects": [')
        bug_data += '{"target": "%s", "status": "%s"}' % (task.target_release,
                                                          task.status)
        bug_data += ('] ,"reviews": [')

        i = 0
        for review in get_reviews_from_bug(task):
            review_status = get_review_status(review)
            if i != 0:
                bug_data += (",")
            i += 1
            review_status = review_status.replace("\n", "")
            bug_data += ('{"review": '
                         '"%s/%s",'
                         '"status": "%s"}' %
                         (GERRIT_URL, review, review_status))
        bug_data += (']}')

        try:
            if counter == 0:
                json.loads(bug_data)
            else:
                json.loads(bug_data[1:])
            f.write(bug_data)
        except (ValueError, UnicodeEncodeError), e:
            print e, '[Bug: %s]' % task.id

        counter += 1
def main():
    parser = argparse.ArgumentParser(description='pull all bugs from a '
                                                 'launchpad project')

    args = parser.parse_args()

#    launchpad = Launchpad.login_anonymously('OpenStack Infra Bugday',
#                                            'production',
#                                            LPCACHEDIR)
#    project = launchpad.projects[LPPROJECT]
    bz = Bugzilla(url=BZURL)

    counter = 0

    nova_status = "Unknown"

    f = open('bugs-refresh.json', 'w')
    f.write('{"date": "%s", "bugs": [' % datetime.datetime.now())

#    for task in project.searchTasks(status=LPSTATUS, importance=LPIMPORTANCE,
#                                    omit_duplicates=True,
#                                    order_by='-importance'):
    bzq = bz.build_query(product=LPPROJECT, status=BZSTATUS)
    #bzq = bz.build_query(bug_id='1154635')
    bugs = bz.query(bzq)
    for task in bugs:
        #if counter == 300:
        #    break
#        bug = launchpad.load(task.bug_link)
#
#        nova_status = 'Unknown'
#        nova_owner = 'Unknown'
#
#        for task in bug.bug_tasks:
#            if task.bug_target_name == LPPROJECT:
#                nova_status = task.status
#                nova_owner = task.assignee
#                break
        try:
            if counter != 0:
                bug_data = ','
            else:
                bug_data = u""
            title = task.summary.replace('"', "'")
            title = title.replace("\n", "")
            title = title.replace("\t", "")
            bug_data += ('{"index": %d, "id": %d, "importance": "%s", '
                         '"status": "%s", '
                         '"owner": "%s", '
                         '"title": "%s", '
                         '"link": "%s"' % (
                             counter,
                             task.id,
                             getBugPriority(task),
                             getBugStatus(task),
                             task.assigned_to,
                             title,
                             task.weburl))

        except (TypeError, UnicodeEncodeError):
            # TODO: fix this
            print 'Error on bug %d', task.id
            counter += 1
            continue

        age = delta(datetime.datetime.strptime("%s" % task.creation_time, "%Y%m%dT%H:%M:%S"))
        updated = delta(datetime.datetime.strptime("%s" % task.last_change_time, "%Y%m%dT%H:%M:%S"))
        stale = False
        if updated > 30 and age > 30:
            if task.status == 'ASSIGNED':
                stale = True
        bug_data += (',"age": %d, "update": %d, "stale": %d, '
                     '"never_touched": %d' %
                     (age, updated, 1 if stale else 0, 1 if len(task.comments) == 1 else 0))

        i = 0
        bug_data += ( ',"projects": [')
        bug_data += '{"target": "%s", "status": "%s"}' % (task.target_release, task.status)
        bug_data += ('] ,"reviews": [')

        i = 0
        for review in get_reviews_from_bug(task):
            review_status = get_review_status(review)
            if i != 0:
                bug_data += (",")
            i += 1
            review_status = review_status.replace("\n", "")
            bug_data += ('{"review": '
                         '"%s/%s",'
                         '"status": "%s"}'
                         % (GERRIT_URL, review, review_status))
        bug_data += (']}')

        try:
            if counter == 0:
                json.loads(bug_data)
            else:
                json.loads(bug_data[1:])
            f.write(bug_data)
        except (ValueError, UnicodeEncodeError), e:
            print e, '[Bug: %s]' % task.id

        counter += 1