コード例 #1
0
ファイル: schema_updater.py プロジェクト: jdzla/openmolar1
    def __init__(self):
        self.pb = QtGui.QProgressDialog()
        self.pb.canceled.connect(user_quit)

        required = localsettings.CLIENT_SCHEMA_VERSION
        self.current = schema_version.getVersion()

        message = MESSAGE.replace("{OLD}", self.current).replace("{NEW}", required)

        if (
            QtGui.QMessageBox.question(
                None, "Update Schema", message, QtGui.QMessageBox.No | QtGui.QMessageBox.Yes, QtGui.QMessageBox.No
            )
            == QtGui.QMessageBox.Yes
        ):
            self.pb.setWindowTitle("openMolar")
            self.pb.show()
        else:
            self.completed(False, ABORT_MESSAGE)

        self.apply_updates()

        if schema_version.getVersion() == required:
            self.pb.destroy()
            proceed()
        else:
            self.completed(False, FAILURE_MESSAGE)
コード例 #2
0
ファイル: main.py プロジェクト: jdzla/openmolar1
def proceed():
    '''
    check db schema, and proceed if all is well
    '''
    # this import will set up gettext and logging
    from openmolar.dbtools import schema_version

    LOGGER.debug("checking schema version...")

    sv = schema_version.getVersion()

    run_main = False

    if IGNORE_SCHEMA_CHECK or localsettings.CLIENT_SCHEMA_VERSION == sv:
        run_main = True

    elif localsettings.CLIENT_SCHEMA_VERSION > sv:
        print "schema is out of date"
        from openmolar.qt4gui import schema_updater
        sys.exit(schema_updater.main())

    elif localsettings.CLIENT_SCHEMA_VERSION < sv:
        print "client is out of date....."
        compatible  = schema_version.clientCompatibility(
            localsettings.CLIENT_SCHEMA_VERSION)

        if not compatible:
            QtGui.QMessageBox.warning(None, _("Update Client"),
            _('''<p>Sorry, you cannot run this version of the openMolar client
because your database schema is more advanced.</p>
<p>this client requires schema version %s, but your database is at %s</p>
<p>Please Update openMolar now</p>''')% (
            localsettings.CLIENT_SCHEMA_VERSION, sv))
        else:
            result = QtGui.QMessageBox.question(None,
            _("Proceed without upgrade?"),
            _('''<p>This openMolar client has fallen behind your database
schema version<br />this client was written for schema version %s,
but your database is now at %s<br />However, the differences are not critical,
and you can continue if you wish</p>
<p><i>It would still be wise to update this client ASAP</i></p>
<hr /><p>Do you wish to continue?</p>''')% (
            localsettings.CLIENT_SCHEMA_VERSION, sv),
            QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
            QtGui.QMessageBox.Yes )

            if result == QtGui.QMessageBox.Yes:
                run_main = True

    if run_main:
        from openmolar.qt4gui import maingui
        maingui.main(my_app)
    else:
        sys.exit()
コード例 #3
0
def proceed():
    '''
    check db schema, and proceed if all is well
    '''
    # this import will set up gettext and logging
    from openmolar.dbtools import schema_version

    LOGGER.debug("checking schema version...")

    sv = schema_version.getVersion()

    run_main = False

    if IGNORE_SCHEMA_CHECK or localsettings.CLIENT_SCHEMA_VERSION == sv:
        run_main = True

    elif localsettings.CLIENT_SCHEMA_VERSION > sv:
        print "schema is out of date"
        from openmolar.qt4gui import schema_updater
        sys.exit(schema_updater.main())

    elif localsettings.CLIENT_SCHEMA_VERSION < sv:
        print "client is out of date....."
        compatible = schema_version.clientCompatibility(
            localsettings.CLIENT_SCHEMA_VERSION)

        if not compatible:
            QtGui.QMessageBox.warning(None, _("Update Client"),
                                      _('''<p>Sorry, you cannot run this version of the openMolar client
because your database schema is more advanced.</p>
<p>this client requires schema version %s, but your database is at %s</p>
<p>Please Update openMolar now</p>''') % (
                                      localsettings.CLIENT_SCHEMA_VERSION, sv))
        else:
            result = QtGui.QMessageBox.question(None,
                                                _("Proceed without upgrade?"),
                                                _('''<p>This openMolar client has fallen behind your database
schema version<br />this client was written for schema version %s,
but your database is now at %s<br />However, the differences are not critical,
and you can continue if you wish</p>
<p><i>It would still be wise to update this client ASAP</i></p>
<hr /><p>Do you wish to continue?</p>''') % (
                                                localsettings.CLIENT_SCHEMA_VERSION, sv),
                                                QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
                                                QtGui.QMessageBox.Yes)

            if result == QtGui.QMessageBox.Yes:
                run_main = True

    if run_main:
        from openmolar.qt4gui import maingui
        maingui.main(my_app)
    else:
        sys.exit()
コード例 #4
0
ファイル: schema_updater.py プロジェクト: pqyptixa/openmolar1
    def apply_updates(self):
        '''
        applies updates until schema is current
        '''
        for version, module in UPGRADES_AVAILABLE:
            self.next_version = version
            if self.current_version < self.next_version:
                upmod = importlib.import_module(module,
                                                "openmolar.schema_upgrades")
                self.dbu = upmod.DatabaseUpdater(self.pb)
                if not self.apply_update():
                    break

        self.dbu = None
        if schema_version.getVersion() == localsettings.CLIENT_SCHEMA_VERSION:
            self.success()
        else:
            self.failure()
コード例 #5
0
ファイル: schema_updater.py プロジェクト: pqyptixa/openmolar1
    def apply_updates(self):
        '''
        applies updates until schema is current
        '''
        for version, module in UPGRADES_AVAILABLE:
            self.next_version = version
            if self.current_version < self.next_version:
                upmod = importlib.import_module(module,
                                                "openmolar.schema_upgrades")
                self.dbu = upmod.DatabaseUpdater(self.pb)
                if not self.apply_update():
                    break

        self.dbu = None
        if schema_version.getVersion() == localsettings.CLIENT_SCHEMA_VERSION:
            self.success()
        else:
            self.failure()
コード例 #6
0
ファイル: schema_updater.py プロジェクト: pqyptixa/openmolar1
 def current_version(self):
     if self._current_version is None:
         self._current_version = schema_version.getVersion()
     return self._current_version
コード例 #7
0
ファイル: schema_updater.py プロジェクト: pqyptixa/openmolar1
 def current_version(self):
     if self._current_version is None:
         self._current_version = schema_version.getVersion()
     return self._current_version
コード例 #8
0
    def apply_updates(self):
        # UPDATE TO SCHEMA 1.1 ########################
        self.next_version = "1.1"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_0to1_1 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.2 ########################
        self.next_version = "1.2"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_1to1_2 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.3 ########################
        self.next_version = "1.3"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_2to1_3 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.4 ########################
        self.next_version = "1.4"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_3to1_4 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.5 ########################
        self.next_version = "1.5"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_4to1_5 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.6 ########################
        self.next_version = "1.6"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_5to1_6 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.7 ########################
        self.next_version = "1.7"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_6to1_7 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.8 ########################
        self.next_version = "1.8"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_7to1_8 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 1.9 ########################
        self.next_version = "1.9"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_8to1_9 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.0 ########################
        self.next_version = "2.0"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema1_9to2_0 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.1 ########################
        self.next_version = "2.1"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_0to2_1 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.2 ########################
        self.next_version = "2.2"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_1to2_2 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.3 ########################
        self.next_version = "2.3"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_2to2_3 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.4 ########################
        self.next_version = "2.4"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_3to2_4 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.5 ########################
        self.next_version = "2.5"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_4to2_5 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.6 ########################
        self.next_version = "2.6"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_5to2_6 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.7 ########################
        self.next_version = "2.7"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_6to2_7 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.8 ########################
        self.next_version = "2.8"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_7to2_8 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 2.9 ########################
        self.next_version = "2.9"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_8to2_9 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 3.0 ########################
        self.next_version = "3.0"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema2_9to3_0 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 3.1 ########################
        self.next_version = "3.1"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema3_0to3_1 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 3.2 ########################
        self.next_version = "3.2"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema3_1to3_2 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        # UPDATE TO SCHEMA 3.3 ########################
        self.next_version = "3.3"
        if self.current_version < self.next_version:
            from openmolar.schema_upgrades import schema3_2to3_3 as upmod
            self.dbu = upmod.DatabaseUpdater(self.pb)
            self.apply_update()

        self.dbu = None
        if schema_version.getVersion() == localsettings.CLIENT_SCHEMA_VERSION:
            self.success()
        else:
            self.failure()