From 82347e4b78ccc7022b2f083b1cdf6346b26046e0 Mon Sep 17 00:00:00 2001 From: Brosef Date: Wed, 10 Jun 2026 07:52:04 +0100 Subject: [PATCH] Added connection check to projects blueprint --- blueprints/projects.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/blueprints/projects.py b/blueprints/projects.py index 7c792b4..a7ce9e3 100644 --- a/blueprints/projects.py +++ b/blueprints/projects.py @@ -31,12 +31,15 @@ class Blueprint(flask.Blueprint): self._apiKey = os.getenv('GITEA_TOKEN') self.giteaUID = None - r = requests.get(self.constructURL('/api/v1/user'), timeout=5) + try: + r = requests.get(self.constructURL('/api/v1/user'), timeout=5) - if r.ok: - self.giteaUID = r.json().get('id') - else: - log.error('Cannot get Gitea user ID. This blueprint will not work.') + if r.ok: + self.giteaUID = r.json().get('id') + else: + log.error('Cannot get Gitea user ID. This blueprint will not work.') + except requests.exceptions.ConnectionError: + log.error('Failed to connect to Gitea server. This blueprint will not work.') super().__init__(*args, **kwargs)