Пример #1
0
def get_inconsistent_reports():
    LOG.info("getting inconsistent reports...")
    inconsistent = []
    today = datetime.datetime.today()
    lp_project = common.get_project_client(PROJECT_NAME)

    bug_tasks = lp_project.searchTasks(status=["In Progress"],
                                       omit_duplicates=True)
    for bug_task in bug_tasks:
        if not bug_task.assignee:
            # remove the timezone info as it disturbs the calculation of the diff
            diff = today - bug_task.date_created.replace(tzinfo=None)
            inconsistent.append(common.BugReport(link=bug_task.web_link,
                                                 title=bug_task.bug.title,
                                                 age=diff.days))

    bug_tasks = lp_project.searchTasks(status=["New", "Confirmed", "Triaged"],
                                       omit_duplicates=True)
    for bug_task in bug_tasks:
        if bug_task.assignee:
            # remove the timezone info as it disturbs the calculation of the diff
            diff = today - bug_task.date_created.replace(tzinfo=None)
            inconsistent.append(common.BugReport(link=bug_task.web_link,
                                                 title=bug_task.bug.title,
                                                 age=diff.days))
    LOG.info("got inconsistent reports")
    return inconsistent
def get_incomplete_reports():
    LOG.info("getting incomplete reports...")
    client = common.get_project_client(PROJECT_NAME)
    bug_tasks = client.searchTasks(status=["Incomplete"],
                                   omit_duplicates=True)
    
    today = datetime.datetime.today()
    reports = []
    
    for bug_task in bug_tasks:
        # remove the timezone info as it disturbs the calculation of the diff
        diff = today - bug_task.date_incomplete.replace(tzinfo=None)
        if diff.days > DAYS_SINCE_INCOMPLETE:
            reports.append(common.BugReport(link=bug_task.web_link,
                                     title=bug_task.bug.title,
                                     age=diff.days))
    LOG.info("got incomplete reports.")
    return reports
import common

parser = argparse.ArgumentParser()
parser.add_argument('-p',
                    '--project-name',
                    required=True,
                    dest='project_name',
                    help='The LP project name.')

args = parser.parse_args()

PROJECT_NAME = args.project_name
DAYS_SINCE_IN_PROGRESS = 14

client = common.get_project_client(PROJECT_NAME)
bug_tasks = client.searchTasks(status=["In Progress"],
                                omit_duplicates=True)

print("potentially stale bugs:")
print("=======================")
today = datetime.datetime.today()
counter = 0

for bug_task in sorted(bug_tasks, key=lambda bug_task: bug_task.date_in_progress):
    # remove the timezone info as it disturbs the calculation of the diff
    diff = today - bug_task.date_in_progress.replace(tzinfo=None)
    if diff.days > DAYS_SINCE_IN_PROGRESS:
        gerrit_url="https://review.openstack.org/"
        review_url = gerrit_url + "/changes/?q=status:open+message:"+str(bug_task.bug.id)
        response = requests.get(review_url)