aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <gueux@gueux.org>2013-01-08 12:11:18 +0100
committerFélix Sipma <gueux@gueux.org>2013-01-08 12:11:18 +0100
commitc2a693be3d42136c1da6ef048d36b764f2e239d5 (patch)
tree70a9a91536743f53b1d41522df2a6c6bb171cb0c
parent821314521018e9497ed068ea79e48df13c325f28 (diff)
copy_movie management command: fix bug with os.path.basename
-rw-r--r--videodb/management/commands/copy_movie.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/videodb/management/commands/copy_movie.py b/videodb/management/commands/copy_movie.py
index fbc44eb..70b9189 100644
--- a/videodb/management/commands/copy_movie.py
+++ b/videodb/management/commands/copy_movie.py
@@ -7,6 +7,7 @@ import warnings
import logging
from videodb import settings
from django.contrib.sites.models import get_current_site
+import os
logger = logging.getLogger(__name__)
@@ -37,6 +38,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
ofile = options.get('file')
+ filename = os.path.basename(ofile)
oid = options.get('id')
imdbid = options.get('imdbid')
search = options.get('search')
@@ -44,8 +46,8 @@ class Command(BaseCommand):
delete = options.get('delete')
if ofile:
- movies = Movie.objects.filter(file__filename__exact = ofile)
- logger.info('select movies corresponding to file "%s".' % ofile)
+ movies = Movie.objects.filter(file__filename__exact = filename)
+ logger.info('select movies corresponding to file "%s".' % filename)
if oid:
movies = movies.filter(id__exact = oid)
@@ -71,11 +73,11 @@ class Command(BaseCommand):
logger.info("Creating directory \"%s\"." % directorspath)
os.makedirs(directorspath)
#realfile = os.path.realpath(ofile)
- moviepath = os.path.join(directorspath, os.path.basename(ofile))
+ moviepath = os.path.join(directorspath, filename)
logger.info("Copying file \"%(file)s\" to \"%(path)s\"." % { 'file': ofile, 'path': moviepath })
shutil.copyfile(ofile, moviepath)
movies_dir = settings.MOVIES_DIR
- link_name = os.path.join(movies_dir, os.path.basename(ofile))
+ link_name = os.path.join(movies_dir, filename)
source = os.path.relpath(moviepath, movies_dir)
logger.info("Creating symlink \"%(link_name)s\" -> \"%(source)s\"." % { 'link_name': link_name, 'source': source })
os.symlink(source, link_name)