Esempio n. 1
0
 def acceptdlg(self):
     '''
     On user clicking the login button
     '''
     isValid = self.validateInput()
     if isValid:
         #Set user object
         self.__setUser()
         #Get DB connection
         dbconfig = DatabaseConfig()
         dbconn = dbconfig.read()
         if dbconn == None:
             msg = QApplication.translate("LoginDialog","The STDM database connection has not been configured in your system.\nWould you like to configure it now?")
             response = QMessageBox.warning(self, QApplication.translate("LoginDialog","Database Connection"), 
                                            msg, QMessageBox.Yes|QMessageBox.No, QMessageBox.Yes)
             if response == QMessageBox.Yes:
                 dbDlg = dbconnDlg(self)
                 if dbDlg.exec_() == QDialog.Accepted:
                     #set the partial database connection properties
                     dbconn = dbDlg.dbconn
             #Whatever the outcome of the database settings definition process                
             if dbconn == None:
                 return                
         dbconn.User = self.User
         #Test connection
         success, msg = dbconn.validateConnection()
         if success:
             self.dbConn = dbconn
             self.accept()
         else:
             QMessageBox.critical(self, QApplication.translate("LoginDialog","Authentication Failed"), msg)
             self.resetSetting()
             self.onRegistrySettings()
             self.txtPassword.setFocus()
             self.txtPassword.selectAll()
Esempio n. 2
0
 def acceptdlg(self):
     '''
     On user clicking the login button
     '''
     isValid = self.validateInput()
     if isValid:
         #Capture DB connection properties
         host = self.txtHost.text()
         port = self.txtPort.text()
         database = self.txtDatabase.text()
         dbconfig = DatabaseConfig()            
         self.dbconn = DatabaseConnection(host,port,database)
         #Write DB conn object to the registry
         dbconfig.write(self.dbconn)
         self.accept()
Esempio n. 3
0
 def acceptdlg(self):
     '''
     On user clicking the login button
     '''
     isValid = self.validateInput()
     if isValid:
         #Capture DB connection properties
         host = self.txtHost.text()
         port = self.txtPort.text()
         database = self.txtDatabase.text()
         dbconfig = DatabaseConfig()
         self.dbconn = DatabaseConnection(host, port, database)
         #Write DB conn object to the registry
         dbconfig.write(self.dbconn)
         self.accept()
Esempio n. 4
0
 def acceptdlg(self):
     '''
     On user clicking the login button
     '''
     isValid = self.validateInput()
     if isValid:
         #Set user object
         self.__setUser()
         #Get DB connection
         dbconfig = DatabaseConfig()
         dbconn = dbconfig.read()
         if dbconn == None:
             msg = QApplication.translate(
                 "LoginDialog",
                 "The STDM database connection has not been configured in your system.\nWould you like to configure it now?"
             )
             response = QMessageBox.warning(
                 self,
                 QApplication.translate("LoginDialog",
                                        "Database Connection"), msg,
                 QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
             if response == QMessageBox.Yes:
                 dbDlg = dbconnDlg(self)
                 retstatus = dbDlg.exec_()
                 if retstatus == QDialog.Accepted:
                     #set the partial database connection properties
                     dbconn = dbDlg.dbconn
             #Whatever the outcome of the database settings definition process
             if dbconn == None:
                 return
         dbconn.User = self.User
         #Test connection
         success, msg = dbconn.validateConnection()
         if success:
             self.dbConn = dbconn
             self.accept()
         else:
             QMessageBox.critical(
                 self,
                 QApplication.translate("LoginDialog",
                                        "Authentication Failed"), msg)
             self.txtPassword.setFocus()
             self.txtPassword.selectAll()
Esempio n. 5
0
    def acceptdlg(self):
        '''
        On user clicking the login button
        '''
        isValid = self.validateInput()
        if isValid:
            #Capture DB connection properties
            host = self.txtHost.text()
            port = self.txtPort.text()
            database = self.txtDatabase.text()
            dbconfig = DatabaseConfig()
            try:
                self.dbconn = DatabaseConnection(host,port,database)
                #Write DB conn object to the registry
                dbconfig.write(self.dbconn)
            except Exception as ex:
                QMessageBox.critical(self, QApplication.translate("DbConnectionDialog","Error saving settings"),
                                 QApplication.translate("DbConnectionDialog",unicode(ex.message)))

            self.accept()