Skip to content

Commit

Permalink
[FIX] base: avoid crashing if no internet connection
Browse files Browse the repository at this point in the history
  • Loading branch information
fpodoo committed Jun 23, 2017
1 parent 204686f commit 0aea445
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions odoo/addons/base/res/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,11 @@ def find_or_create(self, email):
def _get_gravatar_image(self, email):
email_hash = hashlib.md5(email.lower()).hexdigest()
url = "https://www.gravatar.com/avatar/" + email_hash
res = requests.get(url, params={'d': '404', 's': '128'}, timeout=5)
if res.status_code != requests.codes.ok:
try:
res = requests.get(url, params={'d': '404', 's': '128'}, timeout=5)
if res.status_code != requests.codes.ok:
return False
except requests.exceptions.ConnectionError as e:
return False
return base64.b64encode(res.content)

Expand Down

0 comments on commit 0aea445

Please sign in to comment.