예제 #1
0
def start():
    """Starts the WebApp."""
    # TODO: Figure out these imports
    from partify import admin, history, player, queue, statistics, track, user, vote
    init_db()
    on_startup()
    
    app.logger.debug(app.config)

    if app.config.get('PROFILE', False):
        datetime_string = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
        f = open("tmp/profile%s.log" % datetime_string, "w")
        stream = MergeStream(f)
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, stream)

    if app.config['SERVER'] == 'builtin':
        app.run(host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT'])
    elif app.config['SERVER'] == 'tornado':
        import tornado.options
        from tornado.wsgi import WSGIContainer
        from tornado.httpserver import HTTPServer
        from tornado.ioloop import IOLoop

        tornado.options.enable_pretty_logging()
        http_server = HTTPServer(WSGIContainer(app))
        http_server.listen(app.config['SERVER_PORT'])
        IOLoop.instance().start()
예제 #2
0
def start():
    """Starts the WebApp."""
    # TODO: Figure out these imports
    from partify import admin, history, player, queue, statistics, track, user, vote
    init_db()
    on_startup()

    app.logger.debug(app.config)

    if app.config.get('PROFILE', False):
        datetime_string = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
        f = open("tmp/profile%s.log" % datetime_string, "w")
        stream = MergeStream(f)
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, stream)

    if app.config['SERVER'] == 'builtin':
        app.run(host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT'])
    elif app.config['SERVER'] == 'tornado':
        import tornado.options
        from tornado.wsgi import WSGIContainer
        from tornado.httpserver import HTTPServer
        from tornado.ioloop import IOLoop

        tornado.options.enable_pretty_logging()
        http_server = HTTPServer(WSGIContainer(app))
        http_server.listen(app.config['SERVER_PORT'])
        IOLoop.instance().start()
예제 #3
0
 def _prepare(self):
     self.db_fd = tempfile.mkstemp()
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///%s" % self.db_fd[1]
     init_db()
     set_config_value("TESTING", True)
     on_startup()
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///%s" % self.db_fd[1]
     app.config['TESTING'] = True
     from partify.database import db
     self.db = db
예제 #4
0
 def _prepare(self):
     self.db_fd = tempfile.mkstemp() 
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///%s" % self.db_fd[1]
     init_db()
     set_config_value("TESTING", True)
     on_startup()
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///%s" % self.db_fd[1]
     app.config['TESTING'] = True
     from partify.database import db
     self.db = db
예제 #5
0
def on_startup():
    try:
        load_config_from_db()
    except:
        init_db()
        load_config_from_db()
    ipc.init_times()
    ipc.init_desired_player_state()
    ipc.init_mpd_lock()
    ensure_mpd_playlist_consistency()
    ipc.update_time('playlist', time.time())

    # Start the process which subscribes to MPD events using the IDLE command
    mpd_event_listener = Process(target=on_playlist_update)
    mpd_event_listener.start()
예제 #6
0
def on_startup():
    """Performs all of the actions needed to get the web server up and running."""
    try:
        load_config_from_db()
    except:
        init_db()
        load_config_from_db()
    ipc.init_times()
    ipc.init_desired_player_state()
    ipc.init_mpd_lock()
    ensure_mpd_playlist_consistency()
    ipc.update_time('playlist', time.time())

    # Start the process which subscribes to MPD events using the IDLE command
    if not app.config['TESTING']:
        mpd_event_listener = Process(target=on_playlist_update)
        mpd_event_listener.start()
예제 #7
0
def on_startup():
    """Performs all of the actions needed to get the web server up and running."""
    try:
        load_config_from_db()
    except:
        init_db()
        load_config_from_db()
    ipc.init_times()
    ipc.init_desired_player_state()
    ipc.init_mpd_lock()
    ensure_mpd_playlist_consistency()
    ipc.update_time('playlist', time.time())

    # Start the process which subscribes to MPD events using the IDLE command
    if not app.config['TESTING']:
        mpd_event_listener = Process(target=on_playlist_update)
        mpd_event_listener.start()
예제 #8
0
	def _prepare(self):
		self.db_fd = tempfile.mkstemp()
		app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///%s" % self.db_fd[1]
		app.config['TESTING'] = True
		ipc.init_times()
		init_db()