From 6aaa6ce17d3d70e2e355dc7ade159bdb577bbff3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Apr 2016 16:10:03 +0530 Subject: [PATCH] [fix] Catch ConnectionError while checking gravatar_url --- frappe/utils/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index 2e8e6ba04b..8e88dbd731 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -128,10 +128,14 @@ def has_gravatar(email): return gravatar_url = "https://secure.gravatar.com/avatar/{hash}?d=404&s=200".format(hash=md5.md5(email).hexdigest()) - if requests.get(gravatar_url).status_code==404: + try: + res = requests.get(gravatar_url) + if res.status_code==404: + return '' + else: + return gravatar_url + except requests.exceptions.ConnectionError: return '' - else: - return gravatar_url def get_gravatar(email): gravatar_url = has_gravatar(email)