--- a/E5Network/E5SslCertificatesDialog.py Tue Oct 15 22:03:54 2013 +0200 +++ b/E5Network/E5SslCertificatesDialog.py Fri Oct 18 23:00:41 2013 +0200 @@ -9,11 +9,12 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ -from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, QIODevice, \ - qVersion +from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, \ + QIODevice, qVersion from PyQt4.QtGui import QDialog, QTreeWidgetItem try: - from PyQt4.QtNetwork import QSslCertificate, QSslSocket, QSslConfiguration, QSsl + from PyQt4.QtNetwork import QSslCertificate, QSslSocket, \ + QSslConfiguration, QSsl except ImportError: pass @@ -41,15 +42,23 @@ super(E5SslCertificatesDialog, self).__init__(parent) self.setupUi(self) - self.serversViewButton.setIcon(UI.PixmapCache.getIcon("certificates.png")) - self.serversDeleteButton.setIcon(UI.PixmapCache.getIcon("certificateDelete.png")) - self.serversExportButton.setIcon(UI.PixmapCache.getIcon("certificateExport.png")) - self.serversImportButton.setIcon(UI.PixmapCache.getIcon("certificateImport.png")) + self.serversViewButton.setIcon( + UI.PixmapCache.getIcon("certificates.png")) + self.serversDeleteButton.setIcon( + UI.PixmapCache.getIcon("certificateDelete.png")) + self.serversExportButton.setIcon( + UI.PixmapCache.getIcon("certificateExport.png")) + self.serversImportButton.setIcon( + UI.PixmapCache.getIcon("certificateImport.png")) - self.caViewButton.setIcon(UI.PixmapCache.getIcon("certificates.png")) - self.caDeleteButton.setIcon(UI.PixmapCache.getIcon("certificateDelete.png")) - self.caExportButton.setIcon(UI.PixmapCache.getIcon("certificateExport.png")) - self.caImportButton.setIcon(UI.PixmapCache.getIcon("certificateImport.png")) + self.caViewButton.setIcon( + UI.PixmapCache.getIcon("certificates.png")) + self.caDeleteButton.setIcon( + UI.PixmapCache.getIcon("certificateDelete.png")) + self.caExportButton.setIcon( + UI.PixmapCache.getIcon("certificateExport.png")) + self.caImportButton.setIcon( + UI.PixmapCache.getIcon("certificateImport.png")) self.__populateServerCertificatesTree() self.__populateCaCertificatesTree() @@ -96,7 +105,8 @@ items = self.serversCertificatesTree.findItems(organisation, Qt.MatchFixedString | Qt.MatchCaseSensitive) if len(items) == 0: - parent = QTreeWidgetItem(self.serversCertificatesTree, [organisation]) + parent = QTreeWidgetItem( + self.serversCertificatesTree, [organisation]) else: parent = items[0] @@ -123,9 +133,11 @@ Private slot to show data of the selected server certificate. """ try: - from E5Network.E5SslCertificatesInfoDialog import E5SslCertificatesInfoDialog + from E5Network.E5SslCertificatesInfoDialog import \ + E5SslCertificatesInfoDialog cert = QSslCertificate.fromData( - self.serversCertificatesTree.currentItem().data(0, self.CertRole)) + self.serversCertificatesTree.currentItem().data( + 0, self.CertRole)) dlg = E5SslCertificatesInfoDialog(cert, self) dlg.exec_() except ImportError: @@ -139,17 +151,20 @@ itm = self.serversCertificatesTree.currentItem() res = E5MessageBox.yesNo(self, self.trUtf8("Delete Server Certificate"), - self.trUtf8("""<p>Shall the server certificate really be deleted?</p>""" - """<p>{0}</p>""" - """<p>If the server certificate is deleted, the normal security""" - """ checks will be reinstantiated and the server has to""" - """ present a valid certificate.</p>""")\ + self.trUtf8("""<p>Shall the server certificate really be""" + """ deleted?</p><p>{0}</p>""" + """<p>If the server certificate is deleted, the""" + """ normal security checks will be reinstantiated""" + """ and the server has to present a valid""" + """ certificate.</p>""")\ .format(itm.text(0))) if res: server = itm.text(1) - cert = self.serversCertificatesTree.currentItem().data(0, self.CertRole) + cert = self.serversCertificatesTree.currentItem().data( + 0, self.CertRole) - # delete the selected entry and its parent entry, if it was the only one + # delete the selected entry and its parent entry, + # if it was the only one parent = itm.parent() parent.takeChild(parent.indexOfChild(itm)) if parent.childCount() == 0: @@ -198,11 +213,13 @@ commonStr = ", ".join( cert.subjectInfo(QSslCertificate.CommonName)) else: - commonStr = cert.subjectInfo(QSslCertificate.CommonName) + commonStr = cert.subjectInfo( + QSslCertificate.CommonName) E5MessageBox.warning(self, self.trUtf8("Import Certificate"), - self.trUtf8("""<p>The certificate <b>{0}</b> already exists.""" - """ Skipping.</p>""") + self.trUtf8( + """<p>The certificate <b>{0}</b> already exists.""" + """ Skipping.</p>""") .format(Utilities.decodeString(commonStr))) else: pems.append(cert.toPem() + '\n') @@ -222,7 +239,8 @@ """ Private slot to export the selected server certificate. """ - cert = self.serversCertificatesTree.currentItem().data(0, self.CertRole) + cert = self.serversCertificatesTree.currentItem().data( + 0, self.CertRole) fname = self.serversCertificatesTree.currentItem().text(0)\ .replace(" ", "").replace("\t", "") self.__exportCertificate(fname, cert) @@ -320,7 +338,8 @@ Private slot to show data of the selected CA certificate. """ try: - from E5Network.E5SslCertificatesInfoDialog import E5SslCertificatesInfoDialog + from E5Network.E5SslCertificatesInfoDialog import \ + E5SslCertificatesInfoDialog cert = QSslCertificate.fromData( self.caCertificatesTree.currentItem().data(0, self.CertRole)) dlg = E5SslCertificatesInfoDialog(cert, self) @@ -336,15 +355,17 @@ itm = self.caCertificatesTree.currentItem() res = E5MessageBox.yesNo(self, self.trUtf8("Delete CA Certificate"), - self.trUtf8("""<p>Shall the CA certificate really be deleted?</p>""" - """<p>{0}</p>""" - """<p>If the CA certificate is deleted, the browser""" - """ will not trust any certificate issued by this CA.</p>""")\ + self.trUtf8( + """<p>Shall the CA certificate really be deleted?</p>""" + """<p>{0}</p>""" + """<p>If the CA certificate is deleted, the browser""" + """ will not trust any certificate issued by this CA.</p>""")\ .format(itm.text(0))) if res: cert = self.caCertificatesTree.currentItem().data(0, self.CertRole) - # delete the selected entry and its parent entry, if it was the only one + # delete the selected entry and its parent entry, + # if it was the only one parent = itm.parent() parent.takeChild(parent.indexOfChild(itm)) if parent.childCount() == 0: @@ -358,7 +379,8 @@ pems = QByteArray() for cert in caCerts: pems.append(cert.toPem() + '\n') - Preferences.Prefs.settings.setValue("Help/SystemCertificates", pems) + Preferences.Prefs.settings.setValue( + "Help/SystemCertificates", pems) # delete the certificate from the default certificates self.__updateDefaultConfiguration() @@ -377,11 +399,13 @@ commonStr = ", ".join( cert.subjectInfo(QSslCertificate.CommonName)) else: - commonStr = cert.subjectInfo(QSslCertificate.CommonName) + commonStr = cert.subjectInfo( + QSslCertificate.CommonName) E5MessageBox.warning(self, self.trUtf8("Import Certificate"), - self.trUtf8("""<p>The certificate <b>{0}</b> already exists.""" - """ Skipping.</p>""") + self.trUtf8( + """<p>The certificate <b>{0}</b> already exists.""" + """ Skipping.</p>""") .format(Utilities.decodeString(commonStr))) else: caCerts.append(cert) @@ -389,7 +413,8 @@ pems = QByteArray() for cert in caCerts: pems.append(cert.toPem() + '\n') - Preferences.Prefs.settings.setValue("Help/SystemCertificates", pems) + Preferences.Prefs.settings.setValue( + "Help/SystemCertificates", pems) self.caCertificatesTree.clear() self.__populateCaCertificatesTree() @@ -442,8 +467,9 @@ if not f.open(QIODevice.WriteOnly): E5MessageBox.critical(self, self.trUtf8("Export Certificate"), - self.trUtf8("""<p>The certificate could not be written to file""" - """ <b>{0}</b></p><p>Error: {1}</p>""") + self.trUtf8( + """<p>The certificate could not be written""" + """ to file <b>{0}</b></p><p>Error: {1}</p>""") .format(fname, f.errorString())) return @@ -472,8 +498,9 @@ if not f.open(QIODevice.ReadOnly): E5MessageBox.critical(self, self.trUtf8("Export Certificate"), - self.trUtf8("""<p>The certificate could not be read from file""" - """ <b>{0}</b></p><p>Error: {1}</p>""") + self.trUtf8( + """<p>The certificate could not be read from file""" + """ <b>{0}</b></p><p>Error: {1}</p>""") .format(fname, f.errorString())) return []