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
 def start(self, loginFilePath):
     """
         Reimplemented from AbstractTableController
     """
     self._application = QtGui.QApplication(sys.argv)
     self._mainWindow = MainWindow(self)
     self._mainWindow.setVisible(False)
     loginDialog = LoginDialog(loginFilePath)
     QtCore.QObject.connect(loginDialog, QtCore.SIGNAL("userLoggedIn(QObject)"), self.userLoggedIn)
     loginDialog.setModal(True)
     loginDialog.show()
     sys.exit(self._application.exec_())
Beispiel #3
0
    def login(self):
        log, passwd = LoginDialog.getLoginAndPassword(self) or (None, None)
        if not log or not passwd:
            QMessageBox.warning(self, 'Error', 'Empty username or password!',
                                QMessageBox.Ok)
            return
        self.user = None
        self.user = getLogFromDb(log, passwd)
        if self.user is None:
            QMessageBox.warning(self, 'Error', 'Wrong username or password',
                                QMessageBox.Ok)
            return
        tasks = readData(self.user)
        model.update(tasks)
        model.layoutChanged.emit()

        self.refreshView()
        QMessageBox.information(self, 'Success', f'Hello, {log}!',
                                QMessageBox.Ok)
        self.addNewTaskButton.setEnabled(True)
        self.saveButton.setEnabled(True)
Beispiel #4
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()