Пример #1
0
 def exec_(self):
     while ExtendableDialog.exec_(self):
         self.db_check()
         if self.login_ok:
             if self.reception_radioButton.isChecked():
                 localsettings.station = "reception"
             localsettings.setOperator(self.user1, self.user2)
             self.accept()
             return True
         else:
             # LOGGER.debug("passwords ok %s", self.password_ok)
             # LOGGER.debug("user1 ok %s", self.user1_ok)
             # LOGGER.debug("user2 ok %s", self.user2_ok)
             QtGui.QMessageBox.warning(
                 self.parent(), _("Login Error"),
                 u'<h2>%s %s</h2><em>%s</em>' %
                 (_('Incorrect'), _("User/password combination!"),
                  _('Please Try Again.')))
     return False
Пример #2
0
 def result(self):
     if self.exec_():
         chosen = self.selectedClinician
         change_needed = chosen != localsettings.clinicianInits
         localsettings.clinicianInits = chosen
         localsettings.clinicianNo = localsettings.ops_reverse.get(
             chosen, 0)
         curr_operator = localsettings.operator.split("/")
         u2 = curr_operator[0]
         if u2 == chosen:
             u2 = ""
         if (u2 and QtWidgets.QMessageBox.question(
                 self, _("Confirm"), "%s %s?" %
             (_("Set Clinician as"), chosen),
                 QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes,
                 QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No):
             u2 = ""
         localsettings.setOperator(chosen, u2)
         return (change_needed, chosen)
     return (False, None)
Пример #3
0
 def result(self):
     if self.exec_():
         chosen = self.selectedClinician
         change_needed = chosen != localsettings.clinicianInits
         localsettings.clinicianInits = chosen
         localsettings.clinicianNo = localsettings.ops_reverse.get(
             chosen, 0)
         curr_operator = localsettings.operator.split("/")
         u2 = curr_operator[-1]
         if u2 == chosen:
             u2 = ""
         if u2:
             input = QtGui.QMessageBox.question(self, _("Confirm"),
             _("Set assistant as") + " %s?"% u2,
             QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
             QtGui.QMessageBox.Yes )
             if input == QtGui.QMessageBox.No:
                 u2 = ""
         localsettings.setOperator(chosen, u2)
         return (change_needed, chosen)
     return (False, None)
Пример #4
0
 def exec_(self):
     while ExtendableDialog.exec_(self):
         self.db_check()
         if self.login_ok:
             if self.reception_radioButton.isChecked():
                 localsettings.station = "reception"
             localsettings.setOperator(self.user1, self.user2)
             self.accept()
             return True
         else:
             # LOGGER.debug("passwords ok %s", self.password_ok)
             # LOGGER.debug("user1 ok %s", self.user1_ok)
             # LOGGER.debug("user2 ok %s", self.user2_ok)
             QtGui.QMessageBox.warning(
                 self.parent(),
                 _("Login Error"),
                 u'<h2>%s %s</h2><em>%s</em>' % (
                     _('Incorrect'),
                     _("User/password combination!"),
                     _('Please Try Again.')
                 )
             )
     return False
 def result(self):
     if self.exec_():
         chosen = self.selectedClinician
         change_needed = chosen != localsettings.clinicianInits
         localsettings.clinicianInits = chosen
         localsettings.clinicianNo = localsettings.ops_reverse.get(
             chosen, 0)
         curr_operator = localsettings.operator.split("/")
         u2 = curr_operator[0]
         if u2 == chosen:
             u2 = ""
         if (u2 and
                 QtWidgets.QMessageBox.question(
                     self,
                     _("Confirm"),
                     "%s %s?" % (
                         _("Set Clinician as"), chosen),
                     QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes,
                     QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No):
             u2 = ""
         localsettings.setOperator(chosen, u2)
         return (change_needed, chosen)
     return (False, None)
Пример #6
0
                u2_qstring = dl.user2_lineEdit.text().toAscii().toUpper()

                #-- localsettings module now has user variables.
                #-- allowed_logins in a list of practice staff.
                if not u1_qstring in localsettings.allowed_logins:
                    raise LoginError
                if (u2_qstring !="" and
                not u2_qstring in localsettings.allowed_logins):
                    raise LoginError

                #-- set a variable to allow the main program to run
                localsettings.successful_login = True
                if dl.reception_radioButton.isChecked():
                    localsettings.station = "reception"

                localsettings.setOperator(str(u1_qstring), str(u2_qstring))

                proceed()

            except LoginError:
                QtGui.QMessageBox.warning(my_dialog,
                _("Login Error"),
                u'<h2>%s %s</h2><em>%s</em>'% (
                    _('Incorrect'),
                    _("User/password combination!"),
                    _('Please Try Again.')
                    )
                )
            except Exception as exc:
                LOGGER.exception("UNEXPECTED ERROR")
                message = u'<p>%s</p><p>%s</p><hr /><pre>%s</pre>'% (
Пример #7
0
def main():
    '''
    main function
    '''
    global localsettings, my_app
    my_app = QtGui.QApplication(sys.argv)

    from openmolar.settings import localsettings
    from openmolar.qt4gui.compiled_uis import Ui_startscreen
    localsettings.showVersion()

    uninitiated = True

    def autoreception(arg):  # arg is a QString
        '''
        check to see if the user is special user "rec"
        which implies a reception machine
        '''
        if arg.toLower() == "rec":
            dl.reception_radioButton.setChecked(True)

    def chosenServer(chosenAction):
        '''
        the advanced qmenu has been triggered
        '''
        i = actions.index(chosenAction)

        message = localsettings.server_names[i] + "<br />" + _(
            "This is not the default database - are you sure?")
        if i != 0:
            if QtGui.QMessageBox.question(my_dialog, _("confirm"), message,
                                          QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
                                          QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
                i = 0

        dl.chosenServer = i
        for action in actions:
            action.setChecked(False)
        chosenAction.setChecked(True)
        labelServer(i)

    def labelServer(i):
        def_string = ""
        if i == 0:
            def_string = " (" + _("DEFAULT") + ")"

        dl.chosenServer_label.setText(_("Chosen server") + " - " +
                                      localsettings.server_names[i] + def_string)

    if not FIRST_RUN_TESTING:
        cf_Found = True
        if os.path.exists(localsettings.global_cflocation):
            localsettings.cflocation = localsettings.global_cflocation
            pass
        elif os.path.exists(localsettings.cflocation):
            pass
        else:
            cf_Found = False
    else:
        cf_Found = False

    if not cf_Found:
        message = "<center>%s<br />%s<hr /><em>%s</em></center>" % (
            _("This appears to be your first running of OpenMolar."),
            _("We need to generate a settings file."),
            _("Are you ready to proceed?")
        )

        result = QtGui.QMessageBox.question(None, _("First Run"),
                                            message,
                                            QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
                                            QtGui.QMessageBox.Yes)

        if result == QtGui.QMessageBox.Yes:
            import firstRun
            if not firstRun.run():
                my_app.closeAllWindows()
                sys.exit()
        else:
            my_app.closeAllWindows()
            sys.exit()

    try:
        dom = minidom.parse(localsettings.cflocation)
        sys_password = dom.getElementsByTagName(
            "system_password")[0].firstChild.data

        servernames = dom.getElementsByTagName("connection")

        for i, server in enumerate(servernames):
            nameDict = server.attributes
            try:
                localsettings.server_names.append(nameDict["name"].value)
            except KeyError:
                localsettings.server_names.append("%d" % i + 1)

    except IOError as e:
        LOGGER.warning("still no settings file. quitting politely")
        QtGui.QMessageBox.information(None, _("Unable to Run OpenMolar"),
                                      _("Good Bye!"))

        QtGui.QApplication.instance().closeAllWindows()
        sys.exit("unable to run - openMolar couldn't find a settings file")

    my_dialog = QtGui.QDialog()
    dl = Ui_startscreen.Ui_Dialog()
    dl.setupUi(my_dialog)

    PASSWORD, USER1, USER2 = localsettings.autologin()
    dl.password_lineEdit.setText(PASSWORD)
    dl.user1_lineEdit.setText(USER1)
    dl.user2_lineEdit.setText(USER2)
    autoreception(QtCore.QString(USER1))
    autoreception(QtCore.QString(USER2))

    servermenu = QtGui.QMenu()
    dl.chosenServer = 0
    labelServer(0)
    actions = []
    if len(localsettings.server_names) > 1:
        for name in localsettings.server_names:
            action = QtGui.QAction(name, servermenu)
            servermenu.addAction(action)
            dl.advanced_toolButton.setMenu(servermenu)
            actions.append(action)
    else:
        dl.advanced_frame.hide()

    servermenu.connect(servermenu,
                       QtCore.SIGNAL("triggered (QAction *)"), chosenServer)

    QtCore.QObject.connect(dl.user1_lineEdit,
                           QtCore.SIGNAL("textEdited (const QString&)"), autoreception)

    while True:
        if (PASSWORD != "" and USER1 != "") or my_dialog.exec_():
            PASSWORD = ""

            changedServer = localsettings.chosenserver != dl.chosenServer

            localsettings.setChosenServer(dl.chosenServer)

            try:
                #--"salt" the password
                pword = "diqug_ADD_SALT_3i2some" + str(
                    dl.password_lineEdit.text())
                #-- hash the salted password (twice!) and compare to the value
                #-- stored in /etc/openmolar/openmolar.conf (linux)
                stored_password = hashlib.md5(
                    hashlib.sha1(pword).hexdigest()).hexdigest()

                if stored_password != sys_password:
                    #-- end password check
                    raise LoginError

                if uninitiated or changedServer:
                    #- user has entered the correct password
                    #- so now we connect to the mysql database
                    #- for the 1st time
                    #- I do it this way so that anyone sniffing the network
                    #- won't see the mysql password until this point
                    #- this could and should possibly still be improved upon
                    #- maybe by using an ssl connection to the server.
                    localsettings.initiateUsers(changedServer)
                    uninitiated = False

                u1_qstring = dl.user1_lineEdit.text().toAscii().toUpper()
                u2_qstring = dl.user2_lineEdit.text().toAscii().toUpper()

                #-- localsettings module now has user variables.
                #-- allowed_logins in a list of practice staff.
                if not u1_qstring in localsettings.allowed_logins:
                    raise LoginError
                if (u2_qstring != "" and
                   not u2_qstring in localsettings.allowed_logins):
                    raise LoginError

                #-- set a variable to allow the main program to run
                localsettings.successful_login = True
                if dl.reception_radioButton.isChecked():
                    localsettings.station = "reception"

                localsettings.setOperator(str(u1_qstring), str(u2_qstring))

                proceed()

            except LoginError:
                QtGui.QMessageBox.warning(my_dialog,
                                          _("Login Error"),
                                          u'<h2>%s %s</h2><em>%s</em>' % (
                                              _('Incorrect'),
                                              _("User/password combination!"),
                                              _('Please Try Again.')
                                          )
                                          )
            except Exception as exc:
                LOGGER.exception("UNEXPECTED ERROR")
                message = u'<p>%s</p><p>%s</p><hr /><pre>%s</pre>' % (
                    _("UNEXPECTED ERROR"),
                    _("application cannot run"),
                    exc)

                QtGui.QMessageBox.warning(my_dialog, _("Login Error"), message)
                break
        else:
            break
    QtGui.QApplication.instance().closeAllWindows()
Пример #8
0
 def result(self):
     if self.exec_():
         u2 = self.selectedAssistant
         localsettings.setOperator(localsettings.clinicianInits, u2)
         return (True, u2)
     return (False, None)
Пример #9
0
 def result(self):
     if self.exec_():
         u2 = self.selectedAssistant
         localsettings.setOperator(localsettings.clinicianInits, u2)
         return (True, u2)
     return (False, None)