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._apiKey = os.getenv('GITEA_TOKEN')
|
||||||
self.giteaUID = None
|
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:
|
if r.ok:
|
||||||
self.giteaUID = r.json().get('id')
|
self.giteaUID = r.json().get('id')
|
||||||
else:
|
else:
|
||||||
log.error('Cannot get Gitea user ID. This blueprint will not work.')
|
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)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user