示例#1
0
def store_file():
    os.makedirs(app.config['UPLOAD_DIRECTORY'], exist_ok=True)
    file = request.files['file']
    if file and allowed_file(file.filename):
        file_dest_path = incoming_filename(file.filename)
        file.save(file_dest_path)
        incoming_file = IncomingFile(processed='false', file_path=file_dest_path, uuid=uuid, store_date=datetime.now())
        incoming_file.save()
        # processing file in a background thread
        @copy_current_request_context
        def process_file():
            uploaded_file = AudioFileProcessor(uuid)
            uploaded_file.process()
        gevent.spawn(process_file)
        return render_template('storage.html'), 200
    return render_template('error.html'), 406
示例#2
0
def store_file():
    os.makedirs(app.config['UPLOAD_DIRECTORY'], exist_ok=True)
    file = request.files['file']
    if file and allowed_file(file.filename):
        file_dest_path = incoming_filename(file.filename)
        file.save(file_dest_path)
        incoming_file = IncomingFile(processed='false',
                                     file_path=file_dest_path,
                                     uuid=uuid,
                                     store_date=datetime.now())
        incoming_file.save()
        # processing file in a background thread
        @copy_current_request_context
        def process_file():
            uploaded_file = AudioFileProcessor(uuid)
            uploaded_file.process()

        gevent.spawn(process_file)
        return render_template('storage.html'), 200
    return render_template('error.html'), 406
示例#3
0
try:
    app.config.from_object('bynge.default_settings')
except RuntimeError:
    app.logger.error('could not load default configuration')

if os.environ.get('BYNGE_SETTINGS') is not None:
    app.config.from_envvar('BYNGE_SETTINGS')


# logging
logfile_handler = RotatingFileHandler("{0}/{1}.log".format(app.config['LOG_DIR'], app.name), maxBytes=100000, backupCount=1)
logfile_handler.setLevel(eval("logging.{0}".format(app.config['LOG_LEVEL'])))
logfile_handler.setFormatter(logging.Formatter(app.config['LOG_FORMAT']))
app.logger.addHandler(logfile_handler)


# init ES index and document type mappings
try:
    connections.create_connection(hosts=[app.config['ELASTIC_URL']])
    #Index(name='bynge').delete()
    if not Index(name='bynge').exists():
        Index(name='bynge').settings(number_of_shards=1, number_of_replicas=0).create()
    IncomingFile.init()
    AudioFile.init()
    ApiUser.init()
except:
    app.logger.error("could not initialize elasticsearch, aborting")
    exit(1)


import bynge.views
示例#4
0
    app.config.from_object('bynge.default_settings')
except RuntimeError:
    app.logger.error('could not load default configuration')

if os.environ.get('BYNGE_SETTINGS') is not None:
    app.config.from_envvar('BYNGE_SETTINGS')

# logging
logfile_handler = RotatingFileHandler("{0}/{1}.log".format(
    app.config['LOG_DIR'], app.name),
                                      maxBytes=100000,
                                      backupCount=1)
logfile_handler.setLevel(eval("logging.{0}".format(app.config['LOG_LEVEL'])))
logfile_handler.setFormatter(logging.Formatter(app.config['LOG_FORMAT']))
app.logger.addHandler(logfile_handler)

# init ES index and document type mappings
try:
    connections.create_connection(hosts=[app.config['ELASTIC_URL']])
    #Index(name='bynge').delete()
    if not Index(name='bynge').exists():
        Index(name='bynge').settings(number_of_shards=1,
                                     number_of_replicas=0).create()
    IncomingFile.init()
    AudioFile.init()
    ApiUser.init()
except:
    app.logger.error("could not initialize elasticsearch, aborting")
    exit(1)

import bynge.views