also catch socket errors: Errno 104 (Connection reset by peer)
This commit is contained in:
parent
02527457bb
commit
28e787c3f5
1 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue