def db_check(self): LOGGER.debug("performing db_check") changedServer = localsettings.chosenserver != self.chosen_server localsettings.setChosenServer(self.chosen_server) if self.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) self.uninitiated = False
def db_check(self): LOGGER.debug("performing db_check") changedServer = localsettings.chosenserver != self.chosen_server localsettings.setChosenServer(self.chosen_server) if self.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) self.uninitiated = False
def setUp(self): localsettings.initiateUsers() localsettings.initiate() super().setUp()
def setUp(self): super().setUp() localsettings.initiateUsers() localsettings.initiate() self.mw = QtWidgets.QWidget() self.mw.pt = patient_class.patient(11956)
point of execution for the dialog. ''' if not self.exec_(): return False if not self.noExpire_radioButton.isChecked(): exdate = self.dateEdit.date().toPyDate() else: exdate = None author = str(self.author_comboBox.currentText()) if author == "": author = "Anon" message = self.textEdit.toPlainText().toAscii() if self.viewSurgery_radioButton.isChecked(): type = "surg" elif self.viewReception_radioButton.isChecked(): type = "rec" else: type = "all" return memos.saveMemo(self.sno, author, type, exdate, message, True) if __name__ == "__main__": localsettings.initiateUsers() localsettings.initiate() app = QtGui.QApplication([]) dl = SaveMemoDialog(11956) print dl.getInput()
def apply(self): if db_settings.insert_login(self.username): localsettings.initiateUsers() return True
''' if not self.exec_(): return False if not self.noExpire_radioButton.isChecked(): exdate = self.dateEdit.date().toPyDate() else: exdate = None author = str(self.author_comboBox.currentText()) if author == "": author = "Anon" message = self.textEdit.toPlainText().toAscii() if self.viewSurgery_radioButton.isChecked(): type = "surg" elif self.viewReception_radioButton.isChecked(): type = "rec" else: type = "all" return memos.saveMemo(self.sno, author, type, exdate, message, True) if __name__ == "__main__": localsettings.initiateUsers() localsettings.initiate() app = QtGui.QApplication([]) dl = SaveMemoDialog(11956) print dl.getInput()
def setUp(self): localsettings.initiateUsers() localsettings.initiate() localsettings.loadFeeTables() super().setUp() self.mw = QtWidgets.QWidget()
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
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()