From bac3fa796ed80a94d29d9ed591fa5c8c4df4380d Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 6 Mar 2015 12:59:53 +0100 Subject: [PATCH] add encoder mime_types to env, cleanup --- examples/deploy/nginx/sites-enabled/app.conf | 1 - timeside/core/tools/test_samples.py | 3 ++- .../commands/timeside-tests-boilerplate.py | 12 +++++++++--- timeside/server/models.py | 17 ++++++++++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/examples/deploy/nginx/sites-enabled/app.conf b/examples/deploy/nginx/sites-enabled/app.conf index 38ca77f..1ef52b3 100644 --- a/examples/deploy/nginx/sites-enabled/app.conf +++ b/examples/deploy/nginx/sites-enabled/app.conf @@ -23,7 +23,6 @@ server { } location / { - #proxy_pass django; uwsgi_pass app:8000; include /etc/nginx/uwsgi_params; } diff --git a/timeside/core/tools/test_samples.py b/timeside/core/tools/test_samples.py index 7372d3e..c486481 100644 --- a/timeside/core/tools/test_samples.py +++ b/timeside/core/tools/test_samples.py @@ -79,10 +79,11 @@ class NumpySrc: class SampleArray(object): """Base Class for generating a data sample array""" - def __init__(self, duration=10, samplerate=44100): + def __init__(self, duration=10, samplerate=44100, gain=0.97): self.samplerate = int(samplerate) self.num_samples = int(numpy.ceil(duration * self.samplerate)) self.array = NotImplemented + self.gain = gain @property def time_samples(self): diff --git a/timeside/server/management/commands/timeside-tests-boilerplate.py b/timeside/server/management/commands/timeside-tests-boilerplate.py index dfef99e..2830773 100644 --- a/timeside/server/management/commands/timeside-tests-boilerplate.py +++ b/timeside/server/management/commands/timeside-tests-boilerplate.py @@ -13,16 +13,21 @@ from timeside.core.tools.test_samples import generateSamples class Command(BaseCommand): help = "Setup and run a boilerplate for testing" - def cleanup(self): + def processor_cleanup(self): for processor in Processor.objects.all(): processor.delete() + def result_cleanup(self): + for result in Result.objects.all(): + result.delete() + def handle(self, *args, **options): # NOT for production - self.cleanup() + self.processor_cleanup() + # self.result_cleanup() presets = [] - blacklist =['decoder', 'live', 'gain', 'yaafe'] + blacklist =['decoder', 'live', 'gain'] processors = timeside.core.processor.processors(timeside.core.api.IProcessor) for proc in processors: trig = True @@ -54,3 +59,4 @@ class Command(BaseCommand): task, c = Task.objects.get_or_create(experience=experience, selection=selection) task.status_setter(2) + task.delete() diff --git a/timeside/server/models.py b/timeside/server/models.py index f54a856..0ba1288 100644 --- a/timeside/server/models.py +++ b/timeside/server/models.py @@ -50,6 +50,21 @@ PROCESSOR_PIDS = [(name, [(processor.id(), processor.id()) in timeside.core.processor.processors(proc_type)]) for name, proc_type in _processor_types.items()] +extra_types = { + '.webm': 'video/webm', + '.eaf': 'text/xml', # ELAN Annotation Format + '.trs': 'text/xml', # Trancriber Annotation Format + '.svl': 'text/xml', # Sonic Visualiser layer file + '.TextGrid': 'text/praat-textgrid', # Praat TextGrid annotation file +} + +encoders = timeside.core.processor.processors(timeside.core.api.IEncoder) +for encoder in encoders: + extra_types['.' + encoder.file_extension()] = encoder.mime_type() + +for ext,mime_type in extra_types.items(): + mimetypes.add_type(mime_type, ext) + # Status _FAILED, _DRAFT, _PENDING, _RUNNING, _DONE = 0, 1, 2, 3, 4 STATUS = ((_FAILED, _('failed')), (_DRAFT, _('draft')), @@ -307,7 +322,7 @@ class Task(BaseResource): result.status_setter(_DONE) elif proc.type == 'encoder': result = Result.objects.get(preset=preset, item=item) - # result.mime_type_setter(get_mime_type(result.file.path)) + result.mime_type_setter(get_mime_type(result.file.path)) result.status_setter(_DONE) del proc -- 2.39.5