def setup_services(cls): service.provide('filecache', sqlitecache.SQLiteCache) service.provide('cherrymodel', cherrymodel.CherryModel) service.provide('playlist', playlistdb.PlaylistDB) service.provide('users', userdb.UserDB) service.provide('useroptions', useroptiondb.UserOptionDB) service.provide('dbconnector', database.sql.SQLiteConnector, kwargs={ 'datadir': pathprovider.databaseFilePath(''), 'extension': 'db', 'connargs': {'check_same_thread': False}, })
def setup_services(cls): """setup services: they can be used by other parts of the program to easily access different functions of cherrymusic by registering themselves as service.user """ service.provide('filecache', sqlitecache.SQLiteCache) service.provide('cherrymodel', cherrymodel.CherryModel) service.provide('playlist', playlistdb.PlaylistDB) service.provide('users', userdb.UserDB) service.provide('useroptions', useroptiondb.UserOptionDB) service.provide('dbconnector', database.sql.SQLiteConnector, kwargs={ 'datadir': pathprovider.databaseFilePath(''), 'extension': 'db', 'connargs': {'check_same_thread': False}, })
def _get_user_consent_for_db_schema_update(reasons): import textwrap wrap = lambda r: os.linesep.join( textwrap.wrap(r, initial_indent=' - ', subsequent_indent=" ")) msg = """ ========================================================================== A database schema update is needed and requires your consent. {reasons} To continue without changes, you need to downgrade to an earlier version of CherryMusic. To backup your database files first, abort for now and find them here: {dblocation} ========================================================================== Run schema update? [y/N]: """.format( reasons=(2 * os.linesep).join(wrap(r) for r in reasons), dblocation='\t' + pathprovider.databaseFilePath('')) return input(msg).lower().strip() in ('y',)