From bace3c0d30433895ab5cf0da231cf7d84b8e6c82 Mon Sep 17 00:00:00 2001 From: wznmickey Date: Tue, 23 Jul 2024 21:21:37 +0800 Subject: [PATCH] feat: continue running on user missing in create-teams (#38) --- joint_teapot/workers/gitea.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/joint_teapot/workers/gitea.py b/joint_teapot/workers/gitea.py index 95f594b..91e9de5 100644 --- a/joint_teapot/workers/gitea.py +++ b/joint_teapot/workers/gitea.py @@ -196,9 +196,12 @@ def create_teams_and_repos_by_canvas_groups( }, ) logger.info(f"Team {team_name} created") - self.organization_api.org_add_team_repository( - team.id, self.org_name, repo_name - ) + try: + self.organization_api.org_add_team_repository( + team.id, self.org_name, repo_name + ) + except Exception as e: + logger.warning(e) membership: GroupMembership student_count = 0 for membership in group.get_memberships(): @@ -213,10 +216,14 @@ def create_teams_and_repos_by_canvas_groups( except Exception as e: logger.warning(e) continue - self.organization_api.org_add_team_member(team.id, username) - self.repository_api.repo_add_collaborator( - self.org_name, repo_name, username - ) + try: + self.organization_api.org_add_team_member(team.id, username) + self.repository_api.repo_add_collaborator( + self.org_name, repo_name, username + ) + except Exception as e: + logger.error(e) + continue try: self.repository_api.repo_delete_branch_protection( self.org_name, repo_name, "master"