Example #1
0
def init_project(static_folder, *args):
    runtime_folder = get_runtime_folder()
    if not os.path.exists(runtime_folder):
        os.mkdir(runtime_folder)

    runtime_stream_folder = get_runtime_stream_folder()
    if not os.path.exists(runtime_stream_folder):
        os.mkdir(runtime_stream_folder)

    epg_tmp_folder = get_epg_tmp_folder()
    if not os.path.exists(epg_tmp_folder):
        os.mkdir(epg_tmp_folder)

    app = Flask(__name__, static_folder=static_folder)
    for file in args:
        app.config.from_pyfile(file, silent=False)

    app.wsgi_app = ProxyFix(app.wsgi_app)
    bootstrap = Bootstrap(app)
    db = MongoEngine(app)
    mail = Mail(app)
    socketio = SocketIO(app)
    login_manager = LoginManager(app)

    login_manager.login_view = 'HomeView:signin'

    # socketio
    @socketio.on('connect')
    def connect():
        pass

    @socketio.on('disconnect')
    def disconnect():
        pass

    # defaults flask
    _host = '0.0.0.0'
    _port = 8080
    server_name = app.config.get('SERVER_NAME_FOR_POST')
    sn_host, sn_port = None, None

    if server_name:
        sn_host, _, sn_port = server_name.partition(':')

    host = sn_host or _host
    port = int(sn_port or _port)
    servers_manager = ServiceManager(host, port, socketio)

    omdb_api_key = app.config.get('OMDB_KEY')
    omdb = OMDBClient(apikey=omdb_api_key)

    return app, bootstrap, db, mail, login_manager, servers_manager, omdb
Example #2
0
def init_project(static_folder, *args):
    runtime_folder = get_runtime_folder()
    if not os.path.exists(runtime_folder):
        os.mkdir(runtime_folder)

    runtime_stream_folder = get_runtime_stream_folder()
    if not os.path.exists(runtime_stream_folder):
        os.mkdir(runtime_stream_folder)

    epg_tmp_folder = get_epg_tmp_folder()
    if not os.path.exists(epg_tmp_folder):
        os.mkdir(epg_tmp_folder)

    _app = Flask(__name__, static_folder=static_folder)
    for file in args:
        _app.config.from_pyfile(file, silent=False)

    _app.wsgi_app = ProxyFix(_app.wsgi_app)
    Bootstrap(_app)
    _db = PyModm(_app)
    _mail = Mail(_app)
    _socketio = SocketIO(_app, async_mode='gevent')
    _login_manager = LoginManager(_app)

    _login_manager.login_view = 'HomeView:signin'

    # socketio
    @_socketio.on('connect')
    def connect():
        pass

    @_socketio.on('disconnect')
    def disconnect():
        pass

    # defaults flask
    _host = '0.0.0.0'
    _port = 8080
    server_name = _app.config.get('SERVER_NAME_FOR_POST')
    sn_host, sn_port = None, None

    if server_name:
        sn_host, _, sn_port = server_name.partition(':')

    host = sn_host or _host
    port = int(sn_port or _port)
    _servers_manager = ServiceManager(host, port, _socketio)

    omdb_api_key = _app.config.get('OMDB_KEY')
    _omdb = OMDBClient(apikey=omdb_api_key)

    return _app, _mail, _login_manager, _servers_manager, _omdb, _db
Example #3
0
def init_project(static_folder, *args):
    runtime_folder = get_runtime_folder()
    if not os.path.exists(runtime_folder):
        os.mkdir(runtime_folder)

    runtime_stream_folder = get_runtime_stream_folder()
    if not os.path.exists(runtime_stream_folder):
        os.mkdir(runtime_stream_folder)

    app = Flask(__name__, static_folder=static_folder)
    for file in args:
        app.config.from_pyfile(file, silent=False)

    app.wsgi_app = ProxyFix(app.wsgi_app)
    bootstrap = Bootstrap(app)
    babel = Babel(app)
    db = MongoEngine(app)
    mail = Mail(app)
    socketio = SocketIO(app)
    login_manager = LoginManager(app)

    login_manager.login_view = "HomeView:signin"

    # socketio
    @socketio.on('connect')
    def connect():
        pass

    @socketio.on('disconnect')
    def disconnect():
        pass

    # defaults flask
    _host = '0.0.0.0'
    _port = 8080
    server_name = app.config.get('SERVER_NAME_FOR_POST')
    sn_host, sn_port = None, None

    if server_name:
        sn_host, _, sn_port = server_name.partition(':')

    host = sn_host or _host
    port = int(sn_port or _port)
    support_subscribers = app.config.get('SUBSCRIBERS_SUPPORT')
    servers_manager = SubscribersServiceManager(
        host, port, socketio) if support_subscribers else ServiceManager(
            host, port, socketio)

    return app, bootstrap, babel, db, mail, login_manager, servers_manager
Example #4
0
def init_project(static_folder, *args):
    runtime_folder = get_runtime_folder()
    if not os.path.exists(runtime_folder):
        os.mkdir(runtime_folder)

    runtime_stream_folder = get_runtime_stream_folder()
    if not os.path.exists(runtime_stream_folder):
        os.mkdir(runtime_stream_folder)

    app = Flask(__name__, static_folder=static_folder)
    for file in args:
        app.config.from_pyfile(file, silent=False)

    bootstrap = Bootstrap(app)
    babel = Babel(app)
    db = MongoEngine(app)
    mail = Mail(app)
    socketio = SocketIO(app)
    login_manager = LoginManager(app)

    login_manager.login_view = "HomeView:signin"

    # socketio
    @socketio.on('connect')
    def connect():
        print('Client connected')

    @socketio.on('disconnect')
    def disconnect():
        print('Client disconnected')

    # defaults flask
    _host = '127.0.0.1'
    _port = 5000
    server_name = app.config.get('SERVER_NAME_FOR_POST')
    sn_host, sn_port = None, None

    if server_name:
        sn_host, _, sn_port = server_name.partition(':')

    host = sn_host or _host
    port = int(sn_port or _port)
    servers_manager = ServiceManager(host, port, socketio)

    return app, bootstrap, babel, db, mail, login_manager, servers_manager