def fillWithNoise(): fileServer = model.FileServer('', False) soundServer = model.SoundServer(False) database = model.Database(config.mongoConnect(), config.mongoDatabaseName()) with open("white_noise.ogg", "rb") as soundfile: for i in range(1000000): model.simpleSubmit( { 'attribute1': ''.join(random.sample(string.lowercase, random.randint(3, 7))), 'attribute2': ''.join(random.sample(string.lowercase, random.randint(3, 7))) }, soundfile, fileServer, soundServer, database)
import model import config from gevent import monkey; monkey.patch_all() from bottle import route, run, template, request, abort, redirect, static_file fileServer = model.FileServer(config.fileStorePath()); soundServer = model.SoundServer(); database = model.Database(config.mongoConnect(), config.mongoDatabaseName()); @route('/view/<skip:int>') def view(skip): rows = [['file', 'attributes', 'transcriptions']] limit = 20 for record in database.getRecords(skip, limit): if record.has_key('file'): rows.append( ['<a href="/soundfiles/{0}">play</a>'.format(record.get('file')), record.get('attributes'), record.get('transcriptions')]) return template( 'templates/view', count = database.recordsCount(), rows = rows, left = max(skip - limit, 0), right = max(skip + limit, limit)) @route('/soundfiles/<filepath:path>')