From 4fc6d644eb94cb1c2392c714664721451e4dd483 Mon Sep 17 00:00:00 2001 From: Georg Sieber Date: Tue, 6 Aug 2024 22:13:53 +0200 Subject: [PATCH] unify GUI dialog call --- laps-client/laps_client/laps_gui.py | 30 +++++++++++------------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/laps-client/laps_client/laps_gui.py b/laps-client/laps_client/laps_gui.py index ae624dc..bce283e 100755 --- a/laps-client/laps_client/laps_gui.py +++ b/laps-client/laps_client/laps_gui.py @@ -147,14 +147,15 @@ def OnClickAccept(self): parentWidget.OnClickSearch(None) self.close() else: - parentWidget.showErrorDialog('Error', + parentWidget.showInfoDialog('Error', 'Unable to change expiration date to '+str(newExpirationDateTime)+'.' - +'\n\n'+str(parentWidget.connection.result['message']), parentWidget.tmpDn+' ('+parentWidget.GetConnectionString()+')' + +'\n\n'+str(parentWidget.connection.result['message']), parentWidget.tmpDn+' ('+parentWidget.GetConnectionString()+')', + icon=QMessageBox.Critical ) except Exception as e: # display error - parentWidget.showErrorDialog('Error setting new expiration date', str(e)) + parentWidget.showInfoDialog('Error setting new expiration date', str(e), icon=QMessageBox.Critical) # reset connection parentWidget.server = None parentWidget.connection = None @@ -716,7 +717,7 @@ def decryptPassword(self, blob): return decrypted.decode('utf-8').replace("\x00", "") except Exception as e: if(lastDecryptionError != str(e)): - self.showErrorDialog('Decryption Error', str(e)) + self.showInfoDialog('Decryption Error', str(e), icon=QMessageBox.Critical) lastDecryptionError = str(e) def parseLapsValue(self, ldapValue): @@ -788,7 +789,7 @@ def checkCredentialsAndConnect(self): serverArray.append(ldap3.Server(server['address'], port=port, use_ssl=server['ssl'], tls=self.tlsSettings, get_info=ldap3.ALL)) self.server = ldap3.ServerPool(serverArray, ldap3.FIRST, active=2, exhaust=True) except Exception as e: - self.showErrorDialog('Error connecting to LDAP server', str(e)) + self.showInfoDialog('Error connecting to LDAP server', str(e), icon=QMessageBox.Critical) return False # try to bind to server via Kerberos @@ -850,7 +851,7 @@ def checkCredentialsAndConnect(self): return False self.cfgUsername = '' self.cfgPassword = '' - self.showErrorDialog('Error binding to LDAP server', str(e)) + self.showInfoDialog('Error binding to LDAP server', str(e), icon=QMessageBox.Critical) return False return True # return if connection created successfully @@ -890,7 +891,7 @@ def reconnectForAttributeQuery(self): if(self.cfgUseStartTls): self.connection.start_tls() return True except Exception as e: - self.showErrorDialog('Error binding to LDAP server', str(e)) + self.showInfoDialog('Error binding to LDAP server', str(e), icon=QMessageBox.Critical) return False def createLdapBase(self, conn): @@ -948,7 +949,7 @@ def LoadSettings(self): if(isinstance(tmpLdapAttributes, list) or isinstance(tmpLdapAttributes, dict)): self.cfgLdapAttributes = tmpLdapAttributes except Exception as e: - self.showErrorDialog('Error loading settings file', str(e)) + self.showInfoDialog('Error loading settings file', str(e), icon=QMessageBox.Critical) def SaveSettings(self): try: @@ -975,19 +976,10 @@ def SaveSettings(self): 'use-autotype-enter': self.cfgUseAutotypeEnter, }, json_file, indent=4) except Exception as e: - self.showErrorDialog('Error saving settings file', str(e)) + self.showInfoDialog('Error saving settings file', str(e), icon=QMessageBox.Critical) - def showErrorDialog(self, title, text, additionalText=''): - print('Error: '+text) - msg = QMessageBox() - msg.setIcon(QMessageBox.Critical) - msg.setWindowTitle(title) - msg.setText(text) - msg.setDetailedText(additionalText) - msg.setStandardButtons(QMessageBox.Ok) - retval = msg.exec_() def showInfoDialog(self, title, text, additionalText='', icon=QMessageBox.Information): - print('Info: '+text) + print('Dialog:', title, ':', text, ':', additionalText, ':', icon) msg = QMessageBox() msg.setIcon(icon) msg.setWindowTitle(title)