def startup():
    """Start the client/upgrade
    """
    logger = logging.getLogger(__name__)
    logging.config.fileConfig("logging.ini", disable_existing_loggers=False)

    # Apply app configuration according the config file
    configure()

    # Log the version of client (useful for remote debuging)
    logger.info(ConfigDetails().name + " version: " + ConfigDetails().version)

    # Basic services
    svcDiagnostic = DiagnosticService()
    svcDiagnostic.ProxyDiagnostic()

    # App log
    app = QtGui.QApplication(sys.argv)
    ConfigDetails().logFilePath = (str(QtCore.QDir.currentPath())) + os.sep + "client.log"

    # Continue with standard login dialog
    loginDialog = LoginDialog()
    if loginDialog.exec_() == QtGui.QDialog.Accepted:

        # Main application window
        ui = MainWindow()
        ui.show()
                
        currentExitCode = app.exec_()
        return currentExitCode
Esempio n. 2
0
def startup():
    """Start the client/upgrade
    """
    logger = logging.getLogger(__name__)
    logging.config.fileConfig("logging.ini", disable_existing_loggers=False)

    # Apply app configuration according the config file
    configure()
    # Internationalisation
    # translate()

    # Log the version of client (useful for remote debuging)
    logger.info("RPB desktop client version: " + ConfigDetails().version)
    logger.info("Qt version: " + QT_VERSION_STR)
    logger.info("PyQt version: " + PYQT_VERSION_STR)

    # Basic services
    svcDiagnostic = DiagnosticService()
    svcDiagnostic.ProxyDiagnostic()

    svcHttp = HttpConnectionService(ConfigDetails().rpbHost,
                                    ConfigDetails().rpbHostPort, UserDetails())
    svcHttp.application = ConfigDetails().rpbApplication

    if ConfigDetails().proxyEnabled:
        svcHttp.setupProxy(ConfigDetails().proxyHost,
                           ConfigDetails().proxyPort,
                           ConfigDetails().noProxy)
    if ConfigDetails().proxyAuthEnabled:
        svcHttp.setupProxyAuth(ConfigDetails().proxyAuthLogin,
                               ConfigDetails().proxyAuthPassword)

    # App log
    app = QtGui.QApplication(sys.argv)
    ConfigDetails().logFilePath = (str(
        QtCore.QDir.currentPath())) + os.sep + "client.log"

    # Startup
    if ConfigDetails().isUpgrading is None or ConfigDetails(
    ).isUpgrading == "False":
        # Check whether upgrade was done
        showNotify = False
        if ConfigDetails().upgradeFinished is not None and ConfigDetails(
        ).upgradeFinished == "True":
            # Start upgrade procedure
            svcUpgrade = UpgradeService()
            svcUpgrade.cleanup()
            msg = "RadPlanBio client has been successfully upgraded"
            showNotify = True

        # Continue with standard login dialog
        loginDialog = LoginDialog(svcHttp)
        if loginDialog.exec_() == QtGui.QDialog.Accepted:

            # Main application window
            ui = MainWindow()
            ui.show()

            # Upgrade completed notification
            if showNotify:
                reply = QtGui.QMessageBox.information(ui, "Upgrade completed",
                                                      msg,
                                                      QtGui.QMessageBox.Ok)
                if reply == QtGui.QMessageBox.Ok:
                    showNotify = False

            # Automatic update check at startup
            if (ConfigDetails().startupUpdateCheck):

                # Load version from server, user details updated in login dialog
                latestSoftware = svcHttp.getLatestSoftware(
                    ConfigDetails().identifier)

                if latestSoftware != None:
                    latestVersion = str(latestSoftware.version)
                else:
                    latestVersion = ConfigDetails().version

                cmp = lambda x, y: LooseVersion(x).__cmp__(y)
                canUpgrade = cmp(ConfigDetails().version, latestVersion)
                if canUpgrade < 0:
                    ui.upgradePopup()

            currentExitCode = app.exec_()
            return currentExitCode
        else:
            ApplicationEntityService().quit()
            QtGui.qApp.quit()
    else:
        # Start updater (RadPlanBio-update.exe)
        if platform.system() == "Windows":
            if os.path.isfile("./update/RadPlanBio-update.exe"):
                QtCore.QProcess.startDetached("./update/RadPlanBio-update.exe")
            else:
                QtCore.QProcess.startDetached("python ./update/mainUpdate.py")
        elif platform.system() == "Linux":
            if os.path.isfile("./update/RadPlanBio-update"):
                QtCore.QProcess.startDetached("./update/RadPlanBio-update")
            else:
                QtCore.QProcess.startDetached("python ./update/mainUpdate.py")
        else:
            QtCore.QProcess.startDetached("python ./update/mainUpdate.py")

        # Close this one
        ApplicationEntityService().quit()
        QtGui.qApp.quit()