From cce49850acb690c4f65398343a8d93fca67f39f7 Mon Sep 17 00:00:00 2001 From: cangtianhuang Date: Tue, 13 May 2025 08:33:15 +0000 Subject: [PATCH 1/2] update --- HackathonBot/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HackathonBot/config.py b/HackathonBot/config.py index 0b9e614..eb8b1cc 100644 --- a/HackathonBot/config.py +++ b/HackathonBot/config.py @@ -424,7 +424,7 @@ 'repo_urls': ['https://api.github.com/repos/PFCCLab/PaddleAPITest/pulls'], # 最大的任务ID - 'max_task_id' : 76, + 'max_task_id' : 87, # 忽略不处理的题号,这部分留给人工处理 'un_handle_tasks' : [], @@ -436,7 +436,7 @@ 'type_names' : ["转换功能开发"], # 每个赛题所属的赛道,每个赛道是一个数组 - 'task_types' : [['1-76']], + 'task_types' : [['1-87']], # 该issue相关PR的前缀,用来标识PR是否属于该issue 'pr_prefix' : "P2T support No.", From 1ab896bfeb7a259e11a4b1e0f4403a9746b3e7ce Mon Sep 17 00:00:00 2001 From: cangtianhuang Date: Tue, 13 May 2025 11:21:56 +0000 Subject: [PATCH 2/2] int using try-except --- HackathonBot/utils.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/HackathonBot/utils.py b/HackathonBot/utils.py index 85774fb..e95411e 100644 --- a/HackathonBot/utils.py +++ b/HackathonBot/utils.py @@ -204,12 +204,18 @@ def update_status_by_pull(tasks, pull, config): ids = [] nums = title[start: end].split('、') for num in nums: - if '-' in num: - arr = num.split('-') - arr = [i for i in range(int(arr[0]), int(arr[1]) + 1)] - ids.extend(arr) - else: - ids.append(int(num)) + try: + if '-' in num: + arr = num.split('-') + arr = [i for i in range(int(arr[0]), int(arr[1]) + 1)] + ids.extend(arr) + else: + ids.append(int(num)) + except Exception as e: + comment_to_user({"body": "@{} PR赛题编号【{}】不正确".format(username, num), "id": 'pull-' + str(pull["id"])}, config) + config["comment_to_user_list"].append('pull-' + str(pull["id"])) + logger.error('@{} PR #{}中赛题编号【{}】不正确:'.format(username, pull['html_url'], num)) + return for num in ids: # 防止某些PR编号写错 @@ -303,14 +309,18 @@ def process_comment(comment, config): ids = [] nums = sequence.split('、') for num in nums: - if '-' in num: - arr = num.split('-') - arr = [i for i in range(int(arr[0]), int(arr[1]) + 1)] - ids.extend(arr) - else: - ids.append(int(num)) + try: + if '-' in num: + arr = num.split('-') + arr = [i for i in range(int(arr[0]), int(arr[1]) + 1)] + ids.extend(arr) + else: + ids.append(int(num)) + except Exception as e: + logger.error('@{} 报名的格式不正确'.format(comment_obj['username'])) + config["comment_to_user_list"].append('comment-' + str(comment["id"])) + return None nums = ids - comment_obj['num'] = nums logger.info('{} 报名赛题 {}'.format(comment_obj['username'], str(nums)))