also catch socket errors: Errno 104 (Connection reset by peer)

This commit is contained in:
j 2012-09-27 15:48:42 +02:00
parent 02527457bb
commit 28e787c3f5

View file

@ -4,6 +4,8 @@ from __future__ import division
import os.path
import hashlib
import socket
import urllib2
from django.conf import settings
from django.db import models
@ -81,18 +83,22 @@ class PosterCache(models.Model):
with open(self.image.path, 'w') as f:
f.write(data)
self.save()
except ox.net.urllib2.HTTPError, e:
except urllib2.HTTPError, e:
#import traceback
#print traceback.print_exc()
self.status = e.code
self.failed = True
self.save()
except ox.net.urllib2.URLError, e:
except urllib2.URLError, e:
#import traceback
#print traceback.print_exc()
self.status = e.reason
self.failed = True
self.save()
except socket.error, e:
self.status = e.reason
self.failed = True
self.save()
if self.image:
try:
self.image.width