Exemple #1
0
 def test_can_create_recordings_saver(self):
     worker_types_model = WorkerTypesModel(db)
     recordings_model = RecordingsModel(db, worker_types_model, "/tmp/data",
                                        "localhost")
     recordings_saver = create_recordings_saver("ipc:///tmp/worker",
                                                recordings_model)
     self.assertIsInstance(recordings_saver, RecordingsSaver)
Exemple #2
0
 def test_can_create_recordings_saver(self):
     db = create_db_connection("/tmp/db")
     recordings_saver = create_recordings_saver("ipc:///tmp/worker",
                                                "/tmp/data", db)
     self.assertIsInstance(recordings_saver, RecordingsSaver)
Exemple #3
0
app.config.update(
    SECRET_KEY = '12345',
    DEBUG = True,
    GOOGLE_LOGIN_CLIENT_ID = os.environ['GOOGLE_LOGIN_CLIENT_ID'],
    GOOGLE_LOGIN_CLIENT_SECRET = os.environ['GOOGLE_LOGIN_CLIENT_SECRET'],
    GOOGLE_LOGIN_SCOPES = 'https://www.googleapis.com/auth/userinfo.email',
)

socketio = SocketIO(app)
login_manager = LoginManager(app)
google_login = GoogleLogin(app, login_manager)

db = create_db_connection(os.environ['CONNECTION_STRING'])
users_model = UsersModel(db)
recordings_model = RecordingsModel("/opt/app/static/data", db)
saver = create_recordings_saver("tcp://0.0.0.0:5682", "/opt/app/static/data", recordings_model)


@app.route('/')
def index():
    return render_template('index.html', models=recordings_model.get_models())

@app.route('/recordings/<model_name>')
def recordings(model_name):
    return render_template('recordings.html', recordings=recordings_model.get_recordings(model_name), model_name=model_name)

@app.route('/transcribe')
@app.route('/transcribe/<id>')
def transcribe(id = None):
    if id is None:
        recording = recordings_model.get_random_recording()
Exemple #4
0
import gevent
from flask import Flask
from flask.ext.socketio import SocketIO
from lib import create_recordings_saver
from cloudasr.schema import db
from cloudasr.models import WorkerTypesModel, RecordingsModel


app = Flask(__name__)
app.config.update(
    SECRET_KEY = '12345',
    DEBUG = True,
    SQLALCHEMY_DATABASE_URI = os.environ['CONNECTION_STRING']
)
socketio = SocketIO(app)

db.init_app(app)
with app.app_context():
    db_session = db.create_session({})

worker_types_model = WorkerTypesModel(db_session)
recordings_model = RecordingsModel(db_session, worker_types_model, os.environ['STORAGE_PATH'], os.environ['DOMAIN'])
saver = create_recordings_saver("tcp://0.0.0.0:5682", recordings_model)

if __name__ == "__main__":
    from gevent import monkey
    monkey.patch_all()

    gevent.spawn(saver.run)
    socketio.run(app, host="0.0.0.0", port=80)
Exemple #5
0
                      DEBUG=False,
                      SQLALCHEMY_POOL_RECYCLE=299,
                      SQLALCHEMY_DATABASE_URI=os.environ['CONNECTION_STRING'])
elif 'CONNECTION_STRING_FILE' in os.environ:
    scrfilepath = os.environ['CONNECTION_STRING_FILE']
    fl = open(scrfilepath, "r")
    app.config.update(SECRET_KEY='12345',
                      DEBUG=False,
                      SQLALCHEMY_POOL_RECYCLE=299,
                      SQLALCHEMY_DATABASE_URI=fl.readline().replace('\n', ''))
    fl.close()
else:
    print("Connection string not set")
socketio = SocketIO(app)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
with app.app_context():
    db_session = session

worker_types_model = WorkerTypesModel(db_session)
recordings_model = RecordingsModel(db_session, worker_types_model,
                                   os.environ['STORAGE_PATH'],
                                   os.environ['DOMAIN'])
saver = create_recordings_saver("tcp://0.0.0.0:5682", recordings_model)

if __name__ == "__main__":
    from gevent import monkey
    monkey.patch_all()
    gevent.spawn(saver.run)
    socketio.run(app, host="0.0.0.0", port=80)
Exemple #6
0
app.config.update(
    SECRET_KEY='12345',
    DEBUG=True,
    GOOGLE_LOGIN_CLIENT_ID=os.environ['GOOGLE_LOGIN_CLIENT_ID'],
    GOOGLE_LOGIN_CLIENT_SECRET=os.environ['GOOGLE_LOGIN_CLIENT_SECRET'],
    GOOGLE_LOGIN_SCOPES='https://www.googleapis.com/auth/userinfo.email',
)

socketio = SocketIO(app)
login_manager = LoginManager(app)
google_login = GoogleLogin(app, login_manager)

db = create_db_connection(os.environ['CONNECTION_STRING'])
users_model = UsersModel(db)
recordings_model = RecordingsModel("/opt/app/static/data", db)
saver = create_recordings_saver("tcp://0.0.0.0:5682", "/opt/app/static/data",
                                recordings_model)


@app.route('/')
def index():
    return render_template('index.html', models=recordings_model.get_models())


@app.route('/recordings/<model_name>')
def recordings(model_name):
    return render_template(
        'recordings.html',
        recordings=recordings_model.get_recordings(model_name),
        model_name=model_name)

Exemple #7
0
 def test_can_create_recordings_saver(self):
     db = create_db_connection("/tmp/db")
     recordings_saver = create_recordings_saver("ipc:///tmp/worker", "/tmp/data", db)
     self.assertIsInstance(recordings_saver, RecordingsSaver)
Exemple #8
0
 def test_can_create_recordings_saver(self):
     worker_types_model = WorkerTypesModel(db)
     recordings_model = RecordingsModel(db, worker_types_model, "/tmp/data", "localhost")
     recordings_saver = create_recordings_saver("ipc:///tmp/worker", recordings_model)
     self.assertIsInstance(recordings_saver, RecordingsSaver)