Esempio n. 1
0
 def test_commit_without_close(self):
     app.db.finish_transaction()
     # close the database connection without giving LiveStorage the
     # oppertunity to commit when it's closed.
     app.db.connection.close()
     self.setup_new_database(self.save_path, schema_version=0, object_schemas=self.OBJECT_SCHEMAS)
     app.db.upgrade_database()
     database.initialize()
     self.check_database()
Esempio n. 2
0
 def test_commit_without_close(self):
     app.db.finish_transaction()
     # close the database connection without giving LiveStorage the
     # oppertunity to commit when it's closed.
     app.db.connection.close()
     self.setup_new_database(self.save_path,
                             schema_version=0,
                             object_schemas=self.OBJECT_SCHEMAS)
     app.db.upgrade_database()
     database.initialize()
     self.check_database()
Esempio n. 3
0
 def reload_database(self, path=':memory:', upgrade=True, **kwargs):
     self.shutdown_database()
     self.setup_new_database(path, **kwargs)
     if upgrade:
         if self.allow_db_upgrade_error_dialog:
             # this means that exceptions in the upgrade will be sent to a
             # dialog box.  Be careful with this, if you don't handle the
             # dialog, then the unit tests will hang.
             app.db.upgrade_database()
         else:
             # normal case: use _upgrade_database() because we want
             # exceptions to keep propagating
             app.db._upgrade_database()
     database.initialize()
Esempio n. 4
0
 def reload_database(self, path=':memory:', upgrade=True, **kwargs):
     self.shutdown_database()
     self.setup_new_database(path, **kwargs)
     if upgrade:
         if self.allow_db_upgrade_error_dialog:
             # this means that exceptions in the upgrade will be sent to a
             # dialog box.  Be careful with this, if you don't handle the
             # dialog, then the unit tests will hang.
             app.db.upgrade_database(context='main')
         else:
             # normal case: use _upgrade_database() because we want
             # exceptions to keep propagating
             app.db._upgrade_database(context='main')
     item.setup_change_tracker()
     database.initialize()
Esempio n. 5
0
File: startup.py Progetto: ndim/miro
        app.db.upgrade_database()
    except databaseupgrade.DatabaseTooNewError:
        summary = _("Database too new")
        description = _(
            "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()
    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")
Esempio n. 6
0
        app.db.upgrade_database()
    except databaseupgrade.DatabaseTooNewError:
        summary = _("Database too new")
        description = _(
            "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()