Commit 7d7dab93 authored by fred's avatar fred

use new settings

parent 591507b8
......@@ -8,7 +8,8 @@ from django.template import loader
from django.utils.timezone import now
import xml.etree.ElementTree as ET
from .models import Track, SomaLogLine, ScheduledDiffusion, Jingle, LOCAL_BASE_PATH
from .models import Track, SomaLogLine, ScheduledDiffusion, Jingle
from .app_settings import app_settings
class SomaException(Exception):
......@@ -79,20 +80,20 @@ def add_soma_diffusion(diffusion):
diffusion_path = get_diffusion_file_path(diffusion)
# copy file
if not os.path.exists(LOCAL_BASE_PATH):
if not os.path.exists(app_settings.LOCAL_BASE_PATH):
raise SomaException('soma directory is not available')
local_diffusion_path = os.path.join(LOCAL_BASE_PATH, diffusion_path)
if os.path.exists(local_diffusion_path):
for filename in os.listdir(local_diffusion_path):
os.unlink(os.path.join(local_diffusion_path, filename))
else:
os.mkdir(os.path.join(LOCAL_BASE_PATH, diffusion_path))
os.mkdir(os.path.join(app_settings.LOCAL_BASE_PATH, diffusion_path))
try:
shutil.copyfile(soundfile.file.path,
os.path.join(LOCAL_BASE_PATH, diffusion_path, os.path.basename(soundfile.file.path)))
os.path.join(app_settings.LOCAL_BASE_PATH, diffusion_path, os.path.basename(soundfile.file.path)))
except IOError:
try:
os.rmdir(os.path.join(LOCAL_BASE_PATH, diffusion_path))
os.rmdir(os.path.join(app_settings.LOCAL_BASE_PATH, diffusion_path))
except IOError:
pass
raise SomaException('error copying file to soma')
......
......@@ -21,11 +21,11 @@ from django.views.generic.edit import CreateView, FormView
from django.views.generic.list import ListView
from .forms import UploadTracksForm, TrackMetaForm, TrackSearchForm, CleanupForm
from .models import (SomaLogLine, Track, Artist, NonstopFile, ScheduledDiffusion, Jingle,
Stream, LOCAL_BASE_PATH)
from .models import (SomaLogLine, Track, Artist, NonstopFile, ScheduledDiffusion, Jingle, Stream)
from emissions.models import Nonstop, Diffusion
from . import utils
from .app_settings import app_settings
class SomaDayArchiveView(DayArchiveView):
......@@ -404,4 +404,4 @@ class DelSomaDiffusionView(RedirectView):
def jingle_audio_view(request, *args, **kwargs):
jingle = Jingle.objects.get(id=kwargs['pk'])
return FileResponse(open(os.path.join(LOCAL_BASE_PATH, 'SPOTS', jingle.filepath), 'rb'))
return FileResponse(open(os.path.join(app_settings.LOCAL_BASE_PATH, 'SPOTS', jingle.filepath), 'rb'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment