Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 02ac05793fef7485e9475a55f07eb017d2fdeca2
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Sat Oct 26 00:12:25 2013 +0200
catch IOError from libravatar if there is no network
otherwise libravatar will fail with:
self = <coprs.models.User object at 0xa80e44c>
@property
def gravatar_url(self):
"""Return url to libravatar image."""
return libravatar_url(email = self.mail)
coprs/models.py:133:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
email = u'user1(a)foo.bar', openid = None, https = False, default = None
size = None
def libravatar_url(email=None, openid=None, https=False,
default=None, size=None):
"""
Return a URL to the appropriate avatar
"""
avatar_hash, domain = parse_user_identity(email, openid)
query_string = parse_options(default, size)
delegation_server = lookup_avatar_server(domain, https)
/usr/lib/python2.7/site-packages/libravatar.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
domain = u'foo.bar', https = False
def lookup_avatar_server(domain, https):
"""
Extract the avatar server from an SRV record in the DNS zone
The SRV records should look like this:
_avatars._tcp.example.com. IN SRV 0 0 80
avatars.example.com
_avatars-sec._tcp.example.com. IN SRV 0 0 443
avatars.example.com
"""
DNS.DiscoverNameServers()
/usr/lib/python2.7/site-packages/libravatar.py:165:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def DiscoverNameServers():
import sys
if sys.platform in ('win32', 'nt'):
import win32dns
defaults['server']=win32dns.RegistryResolve()
else:
return ParseResolvConf()
/usr/lib/python2.7/site-packages/DNS/Base.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resolv_path = '/etc/resolv.conf'
def ParseResolvConf(resolv_path="/etc/resolv.conf"):
"parses the /etc/resolv.conf file and sets defaults for name
servers"
global defaults
lines=open(resolv_path).readlines()
E IOError:
[Errno 2] No such file or directory: '/etc/resolv.conf'
---------------------------------------------------------------
coprs_frontend/coprs/models.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/coprs_frontend/coprs/models.py b/coprs_frontend/coprs/models.py
index 002ebcb..11e9073 100644
--- a/coprs_frontend/coprs/models.py
+++ b/coprs_frontend/coprs/models.py
@@ -130,7 +130,10 @@ class User(db.Model, Serializer):
@property
def gravatar_url(self):
"""Return url to libravatar image."""
- return libravatar_url(email = self.mail)
+ try:
+ return libravatar_url(email = self.mail)
+ except IOError:
+ return ""
class Copr(db.Model, Serializer):