def test_backlog(self): databaselog.info("message %s", 1) databaselog.debug("message %s", 2) self.log_filter.reset_records() databaselog.print_old_log_entries() # should have 3 log entries, 1 header, 1 footer, and the 1 for the # info message self.check_db_logs(3)
def clear_icon_cache_orphans(): # delete icon_cache rows from the database with no associated # item/feed/guide. removed_objs = [] for ic in iconcache.IconCache.orphaned_view(): logging.warn("No object for IconCache: %s. Discarding", ic) ic.remove() removed_objs.append(str(ic.url)) if removed_objs: databaselog.info( "Removed IconCache objects without an associated " "db object: %s", ','.join(removed_objs)) yield None # delete files in the icon cache directory that don't belong to IconCache # objects. cachedir = fileutil.expand_filename( app.config.get(prefs.ICON_CACHE_DIRECTORY)) if not os.path.isdir(cachedir): return existingFiles = [ os.path.normcase(os.path.join(cachedir, f)) for f in os.listdir(cachedir) ] yield None knownIcons = iconcache.IconCache.all_filenames() yield None knownIcons = [ os.path.normcase(fileutil.expand_filename(path)) for path in knownIcons ] yield None for filename in existingFiles: if (os.path.exists(filename) and os.path.basename(filename)[0] != '.' and os.path.basename(filename) != 'extracted' and not filename in knownIcons): try: os.remove(filename) except OSError: pass yield None
def clear_icon_cache_orphans(): # delete icon_cache rows from the database with no associated # item/feed/guide. removed_objs = [] for ic in iconcache.IconCache.orphaned_view(): logging.warn("No object for IconCache: %s. Discarding", ic) ic.remove() removed_objs.append(str(ic.url)) if removed_objs: databaselog.info("Removed IconCache objects without an associated " "db object: %s", ','.join(removed_objs)) yield None # delete files in the icon cache directory that don't belong to IconCache # objects. cachedir = fileutil.expand_filename(app.config.get( prefs.ICON_CACHE_DIRECTORY)) if not os.path.isdir(cachedir): return existingFiles = [os.path.normcase(os.path.join(cachedir, f)) for f in os.listdir(cachedir)] yield None knownIcons = iconcache.IconCache.all_filenames() yield None knownIcons = [ os.path.normcase(fileutil.expand_filename(path)) for path in knownIcons] yield None for filename in existingFiles: if (os.path.exists(filename) and os.path.basename(filename)[0] != '.' and os.path.basename(filename) != 'extracted' and not filename in knownIcons): try: os.remove(filename) except OSError: pass yield None
"%(appname)s. You must download the latest version of " "%(appname)s and run that.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}, ) raise StartupError(summary, description) except storedatabase.UpgradeErrorSendCrashReport, e: send_startup_crash_report(e.report) return except storedatabase.UpgradeError: raise StartupError(None, None) database.initialize() downloader.reset_download_stats() end = time.time() logging.timing("Database upgrade time: %.3f", end - start) if app.db.startup_version != app.db.current_version: databaselog.info("Upgraded database from version %s to %s", app.db.startup_version, app.db.current_version) databaselog.print_old_log_entries() models.initialize() if DEBUG_DB_MEM_USAGE: util.db_mem_usage_test() mem_usage_test_event.set() dbupgradeprogress.upgrade_end() app.startup_timer.log_time("after db upgrade") app.icon_cache_updater = iconcache.IconCacheUpdater() setup_global_feeds() # call fix_database_inconsistencies() ASAP after the manual feed is set up fix_database_inconsistencies() logging.info("setup tabs...")
"You have a database that was saved with a newer version of " "%(appname)s. You must download the latest version of " "%(appname)s and run that.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}, ) raise StartupError(summary, description) except storedatabase.UpgradeErrorSendCrashReport, e: send_startup_crash_report(e.report) return except storedatabase.UpgradeError: raise StartupError(None, None) database.initialize() end = time.time() logging.timing("Database upgrade time: %.3f", end - start) if app.db.startup_version != app.db.current_version: databaselog.info("Upgraded database from version %s to %s", app.db.startup_version, app.db.current_version) databaselog.print_old_log_entries() models.initialize() if DEBUG_DB_MEM_USAGE: util.db_mem_usage_test() mem_usage_test_event.set() # MetadataProgressUpdater needs to be installed before ItemInfoCache, # since ItemInfoCache may create items if it uses failsafe mode app.metadata_progress_updater = metadataprogress.MetadataProgressUpdater() app.item_info_cache = iteminfocache.ItemInfoCache() app.item_info_cache.load() dbupgradeprogress.upgrade_end() logging.info("Loading video converters...") conversions.conversion_manager.startup()
def test_warning_logged(self): databaselog.info("message %s", 1) databaselog.debug("message %s", 2) self.check_db_logs(2)
def test_warning_logged(self): self.log_filter.allow = True databaselog.info("message %s", 1) databaselog.debug("message %s", 2) self.check_records(2)