def setUp(self): # Generate test sample files self.samples_dir = tempfile.mkdtemp(dir=settings.MEDIA_ROOT) self.samples = generateSamples(samples_dir=self.samples_dir) # Create test Items for title in self.samples.keys(): Item.objects.create(title=title, source_file=self.samples[title]) self.item_title = 'C4_scale.wav' self.item_uuid = Item.objects.get(title=self.item_title).uuid
def handle(self, *args, **options): media_dir = os.path.join('items', 'tests') samples_dir = os.path.join(settings.MEDIA_ROOT, media_dir) selection, c = Selection.objects.get_or_create(title='Tests') if c | (selection.items.count() == 0): print "---------------------------" print "-- CREATE BOILERPLATE --" print "---------------------------" print " - generate samples" samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = os.path.join(media_dir, filename) item, c = Item.objects.get_or_create(title=title, file=path) if not item in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() presets = [] blacklist = ['decoder', 'live', 'gain', 'vamp'] processors = timeside.core.processor.processors( timeside.core.api.IProcessor) for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create(pid=proc.id()) preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}') presets.append(preset) experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) task, c = Task.objects.get_or_create(experience=experience, selection=selection) if c | task.status != _DONE: task.status = _PENDING task.save()
def setUp(self): # Generate test sample files self.samples_dir = tempfile.mkdtemp(dir=settings.MEDIA_ROOT) self.samples = generateSamples(samples_dir=self.samples_dir) # Create test Items for title in self.samples.keys(): Item.objects.create(title=title, source_file=self.samples[title]) self.item_title = 'C4_scale.wav' self.item_uuid = Item.objects.get(title=self.item_title).uuid # Make all requests in the context of a logged in session. user = User.objects.create_user(username='******', password='******') self.client.login(username='******', password='******')
def handle(self, *args, **options): collection, c = MediaCollection.objects.get_or_create( title=self.code, code=self.code, public_access='full') selection, c = Selection.objects.get_or_create(title='Tests') if c: presets = [] blacklist = ['decoder', 'live', 'gain', 'vamp'] processors = timeside.core.processor.processors( timeside.core.api.IProcessor) for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create( pid=proc.id()) preset, c = Preset.objects.get_or_create( processor=processor, parameters='{}') presets.append(preset) media_dir = 'items' + os.sep + 'tests' samples_dir = settings.MEDIA_ROOT + media_dir samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = media_dir + os.sep + filename item, c = Item.objects.get_or_create(title=title, file=path) if not item in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() mediaitem, c = MediaItem.objects.get_or_create( title=title, code=self.code + '-' + slugify(filename), file=path, collection=collection, public_access='full') experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) task = Task(experience=experience, selection=selection) task.save()
def handle(self, *args, **options): media_dir = os.path.join('items','tests') samples_dir = os.path.join(settings.MEDIA_ROOT, media_dir) selection, c = Selection.objects.get_or_create(title='Tests') if c | (selection.items.count() == 0): print "---------------------------" print "-- CREATE BOILERPLATE --" print "---------------------------" print " - generate samples" samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = os.path.join(media_dir, filename) item, c = Item.objects.get_or_create(title=title, file=path) if not item in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() presets = [] blacklist =['decoder', 'live', 'gain', 'vamp'] processors = timeside.core.processor.processors(timeside.core.api.IProcessor) for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create(pid=proc.id()) preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}') presets.append(preset) experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) task,c = Task.objects.get_or_create(experience=experience, selection=selection) if c | task.status != _DONE : task.status = _PENDING task.save()
def handle(self, *args, **options): collections = MediaCollection.objects.filter(code=self.code) if collections: collection = collections[0] created = False else: collection = MediaCollection(title=self.code, code=self.code, public_access='full') created = True collection.save() #TS# selection, created = Selection.objects.get_or_create(title='Tests') if created: #TS#presets = [] #TS#blacklist =['decoder', 'live', 'gain', 'vamp'] #TS#processors = timeside.core.processor.processors(timeside.core.api.IProcessor) #TS#for proc in processors: #TS# trig = True #TS# for black in blacklist: #TS# if black in proc.id(): #TS# trig = False #TS# if trig: #TS# processor, c = Processor.objects.get_or_create(pid=proc.id()) #TS# preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}') #TS# presets.append(preset) media_dir = 'items' + os.sep + 'tests' samples_dir = settings.MEDIA_ROOT + media_dir samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = media_dir + os.sep + filename #TS#item, c = Item.objects.get_or_create(title=title, file=path) #TS#if not item in selection.items.all(): #TS# selection.items.add(item) #TS#if self.cleanup: #TS# for result in item.results.all(): #TS# result.delete() mediaitem, c = MediaItem.objects.get_or_create( title=title, code=self.code + '-' + slugify(filename), file=path, collection=collection, public_access='full')
def handle(self, *args, **options): collection, c = MediaCollection.objects.get_or_create(title=self.code, code=self.code) selection, c = Selection.objects.get_or_create(title='Tests') if c: presets = [] blacklist =['decoder', 'live', 'gain', 'vamp'] processors = timeside.core.processor.processors(timeside.core.api.IProcessor) for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create(pid=proc.id()) preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}') presets.append(preset) media_dir = 'items' + os.sep + 'tests' samples_dir = settings.MEDIA_ROOT + media_dir samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = media_dir + os.sep + filename item, c = Item.objects.get_or_create(title=title, file=path) if not item in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() mediaitem, c = MediaItem.objects.get_or_create(title=title, code=self.code + '-' + slugify(filename), file=path, collection=collection) experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) task = Task(experience=experience, selection=selection) task.save()
def handle(self, *args, **options): collections = MediaCollection.objects.filter(code=self.code) if collections: collection = collections[0] created = False else: collection = MediaCollection(title=self.code, code=self.code, public_access='full') created = True collection.save() #TS# selection, created = Selection.objects.get_or_create(title='Tests') if created: #TS#presets = [] #TS#blacklist =['decoder', 'live', 'gain', 'vamp'] #TS#processors = timeside.core.processor.processors(timeside.core.api.IProcessor) #TS#for proc in processors: #TS# trig = True #TS# for black in blacklist: #TS# if black in proc.id(): #TS# trig = False #TS# if trig: #TS# processor, c = Processor.objects.get_or_create(pid=proc.id()) #TS# preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}') #TS# presets.append(preset) media_dir = 'items' + os.sep + 'tests' samples_dir = settings.MEDIA_ROOT + media_dir samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = media_dir + os.sep + filename #TS#item, c = Item.objects.get_or_create(title=title, file=path) #TS#if not item in selection.items.all(): #TS# selection.items.add(item) #TS#if self.cleanup: #TS# for result in item.results.all(): #TS# result.delete() mediaitem, c = MediaItem.objects.get_or_create(title=title, code=self.code + '-' + slugify(filename), file=path, collection=collection, public_access = 'full')
def handle(self, *args, **options): media_dir = os.path.join('items', 'tests') samples_dir = os.path.join(settings.MEDIA_ROOT, media_dir) selection, c = Selection.objects.get_or_create(title='Tests') if c | (selection.items.count() == 0): print "---------------------------" print "-- CREATE BOILERPLATE --" print "---------------------------" print " - generate samples" samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = os.path.join(media_dir, filename) item, c = Item.objects.get_or_create(title=title, source_file=path) if not item in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() presets = [] blacklist = ['decoder', 'live', 'gain', 'vamp'] processors = timeside.core.processor.processors( timeside.core.api.IProcessor) for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create(pid=proc.id()) try: preset, c = Preset.objects.get_or_create( processor=processor, parameters='{}') presets.append(preset) except Preset.MultipleObjectsReturned: print Preset.objects.filter(processor=processor, parameters='{}') experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) task, c = Task.objects.get_or_create(experience=experience, selection=selection) if c | task.status != _DONE: task.status = _PENDING task.save() # ---- Graphers ----- for grapher in timeside.core.processor.processors( timeside.core.api.IGrapher): if hasattr(grapher, '_from_analyzer' ) and grapher._from_analyzer and not (grapher._staging): processor, c = Processor.objects.get_or_create( pid=grapher._analyzer.id()) try: preset, c = Preset.objects.get_or_create( processor=processor, parameters=json.dumps(grapher._analyzer_parameters)) except MultipleObjectsReturned: print Preset.objects.get( processor=processor, parameters=grapher._analyzer_parameters) sub_processor, c = SubProcessor.objects.get_or_create( sub_processor_id=grapher._result_id, processor=processor) analysis, c = Analysis.objects.get_or_create( sub_processor=sub_processor, preset=preset, title=grapher._grapher_name) for analysis in Analysis.objects.all(): analysis.parameters_schema = analysis.preset.processor.get_parameters_schema( ) analysis.save()
def handle(self, *args, **options): media_dir = os.path.join('items', 'tests') samples_dir = os.path.join(settings.MEDIA_ROOT, media_dir) verbosity = options.get('verbosity') if verbosity: print("---------------------------") print("-- CREATE BOILERPLATE --") print("---------------------------") # ---------- Test Selection ---------- Selection.objects.get_or_create(title='WASABI') selection, c = Selection.objects.get_or_create(title='Tests') if c | (selection.items.count() == 0): if verbosity: print(" - generate samples") samples = generateSamples(samples_dir=samples_dir) for sample in samples.items(): filename, path = sample title = os.path.splitext(filename)[0] path = os.path.join(media_dir, filename) item, c = Item.objects.get_or_create(title=title, source_file=path) if not item not in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() presets = [] blacklist = ['decoder', 'live', 'gain', 'vamp', 'yaafe'] processors = timeside.core.processor.processors( timeside.core.api.IProcessor) graphers = timeside.core.processor.processors( timeside.core.api.IGrapher) if verbosity: print(" - created presets:") for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create( pid=proc.id(), version=proc.version()) try: if proc in graphers: # TODO: resolve missing Graphers !!! maybe if hasattrb ... else : get_or_greate() # ---- Graphers ----- if hasattr( proc, '_from_analyzer' ) and proc._from_analyzer and not (proc._staging): try: parameters = json.dumps( proc._analyzer_parameters) preset, created = Preset.objects.get_or_create( processor=processor, parameters=parameters) if created and verbosity: print(" " + str(preset)) except MultipleObjectsReturned: print( Preset.objects.get( processor=processor, parameters=json.dumps( proc._analyzer_parameters))) sub_processor, c = SubProcessor.objects.get_or_create( sub_processor_id=proc._result_id, processor=processor) analysis, c = Analysis.objects.get_or_create( sub_processor=sub_processor, preset=preset, title=proc._grapher_name) else: preset, created = Preset.objects.get_or_create( processor=processor, parameters=json.dumps( processor.get_parameters_default())) if created and verbosity: print(" " + str(preset)) presets.append(preset) except Preset.MultipleObjectsReturned: print( Preset.objects.filter(processor=processor, parameters='{}')) # ------------ Providers ------------- providers = timeside.core.provider.providers( timeside.core.api.IProvider) for prov in providers: provider, c = Provider.objects.get_or_create( pid=prov.id(), source_access=prov.ressource_access(), description=prov.description(), name=prov.name()) # ---------- Experience All ---------- experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) # ---- Task All on Test selection ---- task, c = Task.objects.get_or_create(experience=experience, selection=selection) if verbosity and c: print(' - created task:') print(task) if c | task.status != _DONE: task.status = _PENDING task.save() # ------------- Analysis ------------- for analysis in Analysis.objects.all(): analysis.parameters_schema = analysis.preset.processor.get_parameters_schema( ) analysis.save()
def handle(self, *args, **options): media_dir = os.path.join('items', 'tests') samples_dir = os.path.join(settings.MEDIA_ROOT, media_dir) selection, c = Selection.objects.get_or_create(title='Tests') if c | (selection.items.count() == 0): print "---------------------------" print "-- CREATE BOILERPLATE --" print "---------------------------" print " - generate samples" samples = generateSamples(samples_dir=samples_dir) for sample in samples.iteritems(): filename, path = sample title = os.path.splitext(filename)[0] path = os.path.join(media_dir, filename) item, c = Item.objects.get_or_create(title=title, source_file=path) if not item in selection.items.all(): selection.items.add(item) if self.cleanup: for result in item.results.all(): result.delete() presets = [] blacklist = ['decoder', 'live', 'gain', 'vamp'] processors = timeside.core.processor.processors(timeside.core.api.IProcessor) for proc in processors: trig = True for black in blacklist: if black in proc.id(): trig = False if trig: processor, c = Processor.objects.get_or_create(pid=proc.id()) try: preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}') presets.append(preset) except Preset.MultipleObjectsReturned: print Preset.objects.filter(processor=processor, parameters='{}') experience, c = Experience.objects.get_or_create(title='All') for preset in presets: if not preset in experience.presets.all(): experience.presets.add(preset) task, c = Task.objects.get_or_create(experience=experience, selection=selection) if c | task.status != _DONE: task.status = _PENDING task.save() # ---- Graphers ----- for grapher in timeside.core.processor.processors(timeside.core.api.IGrapher): if hasattr(grapher, '_from_analyzer') and grapher._from_analyzer and not(grapher._staging): processor, c = Processor.objects.get_or_create(pid=grapher._analyzer.id()) try: preset, c = Preset.objects.get_or_create(processor=processor, parameters=json.dumps(grapher._analyzer_parameters)) except MultipleObjectsReturned: print Preset.objects.get(processor=processor, parameters=grapher._analyzer_parameters) sub_processor, c = SubProcessor.objects.get_or_create(sub_processor_id=grapher._result_id, processor=processor) analysis, c = Analysis.objects.get_or_create(sub_processor=sub_processor, preset=preset, title=grapher._grapher_name) for analysis in Analysis.objects.all(): analysis.parameters_schema = analysis.preset.processor.get_parameters_schema() analysis.save()