Add catch for failure when system doesn't have required SSL certificates.
This commit is contained in:
parent
c655bad631
commit
30e4f6b266
@ -118,11 +118,15 @@ class User(db.Model):
|
|||||||
def update_all(self): # pragma: no cover
|
def update_all(self): # pragma: no cover
|
||||||
logger.info("Updating all info for %s", self.api_key)
|
logger.info("Updating all info for %s", self.api_key)
|
||||||
if (datetime.utcnow() - self.last_updated) > timedelta(hours=1):
|
if (datetime.utcnow() - self.last_updated) > timedelta(hours=1):
|
||||||
|
try:
|
||||||
self.parse_radicals_and_userdata()
|
self.parse_radicals_and_userdata()
|
||||||
self.parse_kanji()
|
self.parse_kanji()
|
||||||
self.parse_vocabulary()
|
self.parse_vocabulary()
|
||||||
self.last_updated = datetime.utcnow()
|
self.last_updated = datetime.utcnow()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
except requests.exceptions.SSLError:
|
||||||
|
logger.error("%s received an SSL error trying to update. Ensure SSL certs are installed.", self.api_key)
|
||||||
|
raise ValueError('Backend SSL Certificate Error, contact administrator.')
|
||||||
else:
|
else:
|
||||||
logger.warn("%s tried to update too frequently", self.api_key)
|
logger.warn("%s tried to update too frequently", self.api_key)
|
||||||
raise ValueError('Cannot refresh now, try again later.')
|
raise ValueError('Cannot refresh now, try again later.')
|
||||||
|
Loading…
Reference in New Issue
Block a user