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 os.path
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import socket
|
||||||
|
import urllib2
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -81,18 +83,22 @@ class PosterCache(models.Model):
|
||||||
with open(self.image.path, 'w') as f:
|
with open(self.image.path, 'w') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
self.save()
|
self.save()
|
||||||
except ox.net.urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
#import traceback
|
#import traceback
|
||||||
#print traceback.print_exc()
|
#print traceback.print_exc()
|
||||||
self.status = e.code
|
self.status = e.code
|
||||||
self.failed = True
|
self.failed = True
|
||||||
self.save()
|
self.save()
|
||||||
except ox.net.urllib2.URLError, e:
|
except urllib2.URLError, e:
|
||||||
#import traceback
|
#import traceback
|
||||||
#print traceback.print_exc()
|
#print traceback.print_exc()
|
||||||
self.status = e.reason
|
self.status = e.reason
|
||||||
self.failed = True
|
self.failed = True
|
||||||
self.save()
|
self.save()
|
||||||
|
except socket.error, e:
|
||||||
|
self.status = e.reason
|
||||||
|
self.failed = True
|
||||||
|
self.save()
|
||||||
if self.image:
|
if self.image:
|
||||||
try:
|
try:
|
||||||
self.image.width
|
self.image.width
|
||||||
|
|
Loading…
Reference in a new issue