def setup_databases(self, update, dropfiledb, setup): if dropfiledb: update = () database.resetdb(sqlitecache.DBNAME) if setup: update = update or () db_is_ready = database.ensure_current_version( consentcallback=self._get_user_consent_for_db_schema_update) if not db_is_ready: log.i("database schema update aborted. quitting.") sys.exit(1) if update is not None: cacheupdate = threading.Thread(name="Updater", target=self._update_if_necessary, args=(update,)) cacheupdate.start() # self._update_if_necessary(update) if not setup: sys.exit(0)
def setup_cache(testfiles=()): """ Sets up a SQLiteCache instance bound to current `media.basedir`. The basedir is assumed to exist (as it must) and can be initialized with directories and (empty) files. :param list testfiles: Strings of filenames. Names ending in '/' are directories. """ database.resetdb(sqlitecache.DBNAME) database.ensure_current_version(sqlitecache.DBNAME, autoconsent=True) cache = sqlitecache.SQLiteCache() basedir = cherry.config['media.basedir'] assert not os.listdir(basedir) for filename in testfiles: fullpath = os.path.join(basedir, filename) setupTestfile(TestFile(fullpath)) cache.full_update() return cache
def setup_databases(self, update, dropfiledb, setup): """ delete or update the file db if so requested. check if the db schema is up to date """ if dropfiledb: update = () database.resetdb(sqlitecache.DBNAME) if setup: update = update or () db_is_ready = database.ensure_current_version( consentcallback=self._get_user_consent_for_db_schema_update) if not db_is_ready: log.i(_("database schema update aborted. quitting.")) sys.exit(1) if update is not None: cacheupdate = threading.Thread(name="Updater", target=self._update_if_necessary, args=(update,)) cacheupdate.start() # self._update_if_necessary(update) if not setup: CherryMusic.stopAndCleanUp()