Added connection check to projects blueprint
This commit is contained in:
@ -31,12 +31,15 @@ class Blueprint(flask.Blueprint):
|
||||
self._apiKey = os.getenv('GITEA_TOKEN')
|
||||
self.giteaUID = None
|
||||
|
||||
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.')
|
||||
except requests.exceptions.ConnectionError:
|
||||
log.error('Failed to connect to Gitea server. This blueprint will not work.')
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user