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):
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')
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):
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'))