Esempio n. 1
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     if not os.path.exists(self.tempdir):
         os.makedirs(self.tempdir)
     self.setup_downloader_log()
     models.initialize()
     app.in_unit_tests = True
     # reload config and initialize it to temprary
     config.load_temporary()
     self.platform = app.config.get(prefs.APP_PLATFORM)
     database.set_thread(threading.currentThread())
     database.setup_managers()
     self.raise_db_load_errors = True
     app.db = None
     self.reload_database()
     self.setup_new_item_info_cache()
     searchengines._engines = [
         searchengines.SearchEngineInfo(u"all", u"Search All", u"", -1)
         ]
     # reset the event loop
     util.chatter = False
     self.saw_error = False
     self.error_signal_okay = False
     signals.system.connect('error', self.handle_error)
     app.controller = DummyController()
     self.httpserver = None
     httpauth.init()
Esempio n. 2
0
 def setUp(self):
     self.setup_log_filter()
     self.tempdir = tempfile.mkdtemp()
     if not os.path.exists(self.tempdir):
         os.makedirs(self.tempdir)
     self.setup_downloader_log()
     models.initialize()
     app.in_unit_tests = True
     app.device_manager = devices.DeviceManager()
     models.Item._path_count_tracker.reset()
     testobjects.test_started(self)
     # Tweak Item to allow us to make up fake paths for FileItems
     models.Item._allow_nonexistent_paths = True
     # setup the deleted file checker
     item.setup_deleted_checker()
     item.start_deleted_checker()
     # Skip worker proccess for feedparser
     feed._RUN_FEED_PARSER_INLINE = True
     signals.system.connect('new-dialog', self.handle_new_dialog)
     # reload config and initialize it to temprary
     config.load_temporary()
     self.setup_config_watcher()
     self.platform = app.config.get(prefs.APP_PLATFORM)
     self.set_temp_support_directory()
     # for the unittests, both the database code and any UI code should run
     # in the main thread.
     threadcheck.set_eventloop_thread(threading.currentThread())
     threadcheck.set_ui_thread(threading.currentThread())
     self.raise_db_load_errors = True
     app.db = None
     self.allow_db_upgrade_error_dialog = False
     self.reload_database()
     self.setup_new_item_info_cache()
     self.setup_dummy_message_handlers()
     item.setup_metadata_manager(self.tempdir)
     searchengines._engines = [
         searchengines.SearchEngineInfo(u"all", u"Search All", u"", -1)
         ]
     # reset the event loop
     util.chatter = False
     self.saw_error = False
     self.error_signal_okay = False
     signals.system.connect('error', self.handle_error)
     app.controller = DummyController()
     self.httpserver = None
     httpauth.init()
     # reset any logging records from our setUp call()
     self.log_filter.reset_records()
     # create an extension manager that searches our tempdir for extensions
     # NOTE: this doesn't actually load any extensions, since the directory
     # is currently empty.  If you want to use the ExtensionManager you
     # need to put a .miroext file in the tempdir then call
     # app.extension_manager.load_extension()
     app.extension_manager = extensionmanager.ExtensionManager(
             [self.tempdir], [])
     # Create a download state object (but don't start the downloader
     # for the individual test unless necessary.  In this case we override
     # the class to run the downloader).
     app.download_state_manager = downloader.DownloadStateManager()
     self.mock_patchers = []
Esempio n. 3
0
 def setUp(self):
     self.setup_log_filter()
     self.tempdir = tempfile.mkdtemp()
     if not os.path.exists(self.tempdir):
         os.makedirs(self.tempdir)
     self.setup_downloader_log()
     models.initialize()
     app.in_unit_tests = True
     app.device_manager = devices.DeviceManager()
     models.Item._path_count_tracker.reset()
     testobjects.test_started(self)
     # Tweak Item to allow us to make up fake paths for FileItems
     models.Item._allow_nonexistent_paths = True
     # setup the deleted file checker
     item.setup_deleted_checker()
     item.start_deleted_checker()
     # Skip worker proccess for feedparser
     feed._RUN_FEED_PARSER_INLINE = True
     signals.system.connect('new-dialog', self.handle_new_dialog)
     # reload config and initialize it to temprary
     config.load_temporary()
     self.setup_config_watcher()
     self.platform = app.config.get(prefs.APP_PLATFORM)
     self.set_temp_support_directory()
     # for the unittests, both the database code and any UI code should run
     # in the main thread.
     threadcheck.set_eventloop_thread(threading.currentThread())
     threadcheck.set_ui_thread(threading.currentThread())
     self.raise_db_load_errors = True
     app.db = None
     self.allow_db_upgrade_error_dialog = False
     self.reload_database()
     self.setup_new_item_info_cache()
     self.setup_dummy_message_handlers()
     item.setup_metadata_manager(self.tempdir)
     searchengines._engines = [
         searchengines.SearchEngineInfo(u"all", u"Search All", u"", -1)
     ]
     # reset the event loop
     util.chatter = False
     self.saw_error = False
     self.error_signal_okay = False
     signals.system.connect('error', self.handle_error)
     app.controller = DummyController()
     self.httpserver = None
     httpauth.init()
     # reset any logging records from our setUp call()
     self.log_filter.reset_records()
     # create an extension manager that searches our tempdir for extensions
     # NOTE: this doesn't actually load any extensions, since the directory
     # is currently empty.  If you want to use the ExtensionManager you
     # need to put a .miroext file in the tempdir then call
     # app.extension_manager.load_extension()
     app.extension_manager = extensionmanager.ExtensionManager(
         [self.tempdir], [])
     # Create a download state object (but don't start the downloader
     # for the individual test unless necessary.  In this case we override
     # the class to run the downloader).
     app.download_state_manager = downloader.DownloadStateManager()
     self.mock_patchers = []
Esempio n. 4
0
 def setUp(self):
     self.setup_log_filter()
     self.tempdir = tempfile.mkdtemp()
     if not os.path.exists(self.tempdir):
         os.makedirs(self.tempdir)
     self.setup_downloader_log()
     models.initialize()
     app.in_unit_tests = True
     # Tweak Item to allow us to make up fake paths for FileItems
     models.Item._allow_nonexistent_paths = True
     # setup movie data stuff
     self.metadata_progress_updater = FakeMetadataProgressUpdater()
     app.metadata_progress_updater = self.metadata_progress_updater
     moviedata.movie_data_updater = moviedata.MovieDataUpdater()
     # Skip worker proccess for feedparser
     feed._RUN_FEED_PARSER_INLINE = True
     # reload config and initialize it to temprary
     config.load_temporary()
     self.platform = app.config.get(prefs.APP_PLATFORM)
     database.set_thread(threading.currentThread())
     database.setup_managers()
     self.raise_db_load_errors = True
     app.db = None
     self.reload_database()
     self.setup_new_item_info_cache()
     searchengines._engines = [
         searchengines.SearchEngineInfo(u"all", u"Search All", u"", -1)
     ]
     # reset the event loop
     util.chatter = False
     self.saw_error = False
     self.error_signal_okay = False
     signals.system.connect('error', self.handle_error)
     app.controller = DummyController()
     self.httpserver = None
     httpauth.init()
     # reset any logging records from our setUp call()
     self.log_filter.reset_records()
Esempio n. 5
0
 def setUp(self):
     self.setup_log_filter()
     self.tempdir = tempfile.mkdtemp()
     if not os.path.exists(self.tempdir):
         os.makedirs(self.tempdir)
     self.setup_downloader_log()
     models.initialize()
     app.in_unit_tests = True
     # Tweak Item to allow us to make up fake paths for FileItems
     models.Item._allow_nonexistent_paths = True
     # setup movie data stuff
     self.metadata_progress_updater = FakeMetadataProgressUpdater()
     app.metadata_progress_updater = self.metadata_progress_updater
     moviedata.movie_data_updater = moviedata.MovieDataUpdater()
     # Skip worker proccess for feedparser
     feed._RUN_FEED_PARSER_INLINE = True
     # reload config and initialize it to temprary
     config.load_temporary()
     self.platform = app.config.get(prefs.APP_PLATFORM)
     database.set_thread(threading.currentThread())
     database.setup_managers()
     self.raise_db_load_errors = True
     app.db = None
     self.reload_database()
     self.setup_new_item_info_cache()
     searchengines._engines = [
         searchengines.SearchEngineInfo(u"all", u"Search All", u"", -1)
         ]
     # reset the event loop
     util.chatter = False
     self.saw_error = False
     self.error_signal_okay = False
     signals.system.connect('error', self.handle_error)
     app.controller = DummyController()
     self.httpserver = None
     httpauth.init()
     # reset any logging records from our setUp call()
     self.log_filter.reset_records()
Esempio n. 6
0
File: startup.py Progetto: ndim/miro
        )
        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...")
    setup_tabs()
    logging.info("setup theme...")
Esempio n. 7
0
            {"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()
    app.device_manager = devices.DeviceManager()
    app.device_tracker = devicetracker.DeviceTracker()