makedirs
This commit is contained in:
parent
752242e40c
commit
e3ffa98d92
1 changed files with 2 additions and 0 deletions
|
@ -11,6 +11,7 @@ from django.db.models import Q
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
|
||||||
|
import ox
|
||||||
import ox.web.criterion
|
import ox.web.criterion
|
||||||
import ox.web.movieposterdb
|
import ox.web.movieposterdb
|
||||||
import ox.web.imdb
|
import ox.web.imdb
|
||||||
|
@ -76,6 +77,7 @@ class PosterCache(models.Model):
|
||||||
try:
|
try:
|
||||||
data = ox.net.readUrl(url)
|
data = ox.net.readUrl(url)
|
||||||
self.image.name = poster_path(self.url, 'image.jpg')
|
self.image.name = poster_path(self.url, 'image.jpg')
|
||||||
|
ox.makedirs(os.path.dirname(self.image.path))
|
||||||
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()
|
||||||
|
|
Loading…
Reference in a new issue