From 30e4f6b266777039faaacc5e5aad2e9ae6b079fc Mon Sep 17 00:00:00 2001 From: "nathan@archer" Date: Sun, 3 Apr 2016 16:21:00 +0100 Subject: [PATCH] Add catch for failure when system doesn't have required SSL certificates. --- wanikaniburned.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wanikaniburned.py b/wanikaniburned.py index 7ee230e..de435bf 100644 --- a/wanikaniburned.py +++ b/wanikaniburned.py @@ -118,11 +118,15 @@ class User(db.Model): def update_all(self): # pragma: no cover logger.info("Updating all info for %s", self.api_key) if (datetime.utcnow() - self.last_updated) > timedelta(hours=1): - self.parse_radicals_and_userdata() - self.parse_kanji() - self.parse_vocabulary() - self.last_updated = datetime.utcnow() - db.session.commit() + try: + self.parse_radicals_and_userdata() + self.parse_kanji() + self.parse_vocabulary() + self.last_updated = datetime.utcnow() + 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: logger.warn("%s tried to update too frequently", self.api_key) raise ValueError('Cannot refresh now, try again later.')