Example #1
0
def auto_reply(item, request_repo, rest_repo, duplicated_issue, python_piplines, assigner_repoes):
    logging.info("new issue number: {}".format(item.issue_object.number))
    assigner_repo = assigner_repoes[item.assignee]
    if 'auto-link' not in item.labels:
        item.issue_object.add_to_labels('auto-link')
        try:
            package_name, readme_link, output_folder = update_issue_body(assigner_repo, rest_repo, item.issue_object.number)
            logging.info("pkname, readme", package_name, readme_link)
            item.package = package_name
            key = ('Python', item.package)
            duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
        except Exception as e:
            item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
            item.issue_object.add_to_labels('attention')
            logging.info(e)
            raise
    else:
        try:
            readme_link, output_folder = get_readme_and_output_folder(request_repo, rest_repo, item.issue_object.number)
        except Exception as e:
            logging.info('Issue: {}  get pkname and output folder failed'.format(item.issue_object.number))
            item.bot_advice = 'failed to find Readme link and output folder!  <br>'
            item.issue_object.add_to_labels('attention')
            logging.info(e)
            raise
    try:
        pipeline_url = get_pipeline_url(python_piplines, output_folder)
        begin_reply_generate(item=item, rest_repo=rest_repo, readme_link=readme_link, pipeline_url=pipeline_url)
        if 'Configured' in item.labels:
            item.issue_object.remove_from_labels('Configured')
    except Exception as e:
        item.bot_advice = 'auto reply failed!  <br>'
        logging.info('Error from auto reply')
        logging.info('Issue:{}'.format(item.issue_object.number))
        logging.info(traceback.format_exc())
Example #2
0
def auto_reply(item, sdk_repo, rest_repo, duplicated_issue):
    print("==========new issue number: {}".format(item.issue_object.number))
    if 'auto-link' not in item.labels:
        try:
            package_name, readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
            print("pkname, readme", package_name, readme_link)
            item.package = package_name
            key = ('Python', item.package)
            duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
        except Exception as e:
            item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
            item.labels.append('attention')
            print(e)
            raise
        item.labels.append('auto-link')
        item.issue_object.set_labels(*item.labels)
    else:
        try:
            readme_link = find_readme_link(sdk_repo, item.issue_object.number)
        except Exception as e:
            print('Issue: {}  updates body failed'.format(item.issue_object.number))
            item.bot_advice = 'failed to find Readme link, Please check !!'
            item.labels.append('attention')
            raise
    try:
        reply = rg.begin_reply_generate(item=item, rest_repo=rest_repo, readme_link=readme_link)
    except Exception as e:
        item.bot_advice = 'auto reply failed, Please intervene manually !!'
        print('Error from auto reply ========================')
        print('Issue:{}'.format(item.issue_object.number))
        print(traceback.format_exc())
        print('==============================================')