diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 54dbb8a3..5584d30e 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -1578,7 +1578,13 @@ class MyForm(settingsmixin.SMainWindow): # menu button 'delete all treshed messages' def click_actionDeleteAllTrashedMessages(self): - if QtWidgets.QMessageBox.question(self, _translate("MainWindow", "Delete trash?"), _translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.No: + if QtWidgets.QMessageBox.question( + self, _translate("MainWindow", "Delete trash?"), + _translate( + "MainWindow", + "Are you sure you want to delete all trashed messages?" + ), QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No + ) == QtWidgets.QMessageBox.No: return sqlStoredProcedure('deleteandvacuume') self.rerenderTabTreeMessages() @@ -2071,22 +2077,22 @@ class MyForm(settingsmixin.SMainWindow): toAddress = acct.toAddress else: if QtWidgets.QMessageBox.question( - self, "Sending an email?", - _translate( - "MainWindow", - "You are trying to send an email" - " instead of a bitmessage. This" - " requires registering with a" - " gateway. Attempt to register?" - ), QtWidgets.QMessageBox.Yes - | QtWidgets.QMessageBox.No + self, "Sending an email?", + _translate( + "MainWindow", + "You are trying to send an email" + " instead of a bitmessage. This" + " requires registering with a" + " gateway. Attempt to register?" + ), QtWidgets.QMessageBox.Yes + | QtWidgets.QMessageBox.No ) != QtWidgets.QMessageBox.Yes: continue email = acct.getLabel() # attempt register if email[-14:] != "@mailchuck.com": # 12 character random email address - email = ''.join( + email = u''.join( random.SystemRandom().choice( string.ascii_lowercase ) for _ in range(12) @@ -2108,33 +2114,33 @@ class MyForm(settingsmixin.SMainWindow): decodeAddress(toAddress)[:3] if status != 'success': try: - toAddress = unicode(toAddress, 'utf-8', 'ignore') + toAddress_value = unicode( + toAddress, 'utf-8', 'ignore') except: logger.warning( - "Failed unicode(toAddress ):", - exc_info=True) + "Failed unicode(toAddress ):", exc_info=True) logger.error( 'Error: Could not decode recipient address %s: %s', - toAddress, status) + toAddress_value, status) if status == 'missingbm': self.updateStatusBar(_translate( "MainWindow", "Error: Bitmessage addresses start with" " BM- Please check the recipient address {0}" - ).format(toAddress)) + ).format(toAddress_value)) elif status == 'checksumfailed': self.updateStatusBar(_translate( "MainWindow", "Error: The recipient address {0} is not" " typed or copied correctly. Please check it." - ).format(toAddress)) + ).format(toAddress_value)) elif status == 'invalidcharacters': self.updateStatusBar(_translate( "MainWindow", "Error: The recipient address {0} contains" " invalid characters. Please check it." - ).format(toAddress)) + ).format(toAddress_value)) elif status == 'versiontoohigh': self.updateStatusBar(_translate( "MainWindow", @@ -2142,7 +2148,7 @@ class MyForm(settingsmixin.SMainWindow): " {0} is too high. Either you need to upgrade" " your Bitmessage software or your" " acquaintance is being clever." - ).format(toAddress)) + ).format(toAddress_value)) elif status == 'ripetooshort': self.updateStatusBar(_translate( "MainWindow", @@ -2150,7 +2156,7 @@ class MyForm(settingsmixin.SMainWindow): " address {0} is too short. There might be" " something wrong with the software of" " your acquaintance." - ).format(toAddress)) + ).format(toAddress_value)) elif status == 'ripetoolong': self.updateStatusBar(_translate( "MainWindow", @@ -2158,7 +2164,7 @@ class MyForm(settingsmixin.SMainWindow): " address {0} is too long. There might be" " something wrong with the software of" " your acquaintance." - ).format(toAddress)) + ).format(toAddress_value)) elif status == 'varintmalformed': self.updateStatusBar(_translate( "MainWindow", @@ -2166,13 +2172,13 @@ class MyForm(settingsmixin.SMainWindow): " address {0} is malformed. There might be" " something wrong with the software of" " your acquaintance." - ).format(toAddress)) + ).format(toAddress_value)) else: self.updateStatusBar(_translate( "MainWindow", "Error: Something is wrong with the" " recipient address {0}." - ).format(toAddress)) + ).format(toAddress_value)) elif fromAddress == '': self.updateStatusBar(_translate( "MainWindow", @@ -2478,7 +2484,7 @@ class MyForm(settingsmixin.SMainWindow): dialog.exec_() try: address, label = dialog.data - except AttributeError: + except (AttributeError, TypeError): return # First we must check to see if the address is already in the @@ -2523,7 +2529,7 @@ class MyForm(settingsmixin.SMainWindow): dialog.exec_() try: address, label = dialog.data - except AttributeError: + except (AttributeError, TypeError): return # We must check to see if the address is already in the @@ -2582,9 +2588,8 @@ class MyForm(settingsmixin.SMainWindow): dialog = dialogs.EmailGatewayDialog(self, config=BMConfigParser()) # For Modal dialogs dialog.exec_() - try: - acct = dialog.data - except AttributeError: + acct = dialog.data + if not acct: return # Only settings remain here @@ -3239,10 +3244,9 @@ class MyForm(settingsmixin.SMainWindow): defaultFilename = "".join( x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt' - filename, filetype = QtWidgets.QFileDialog.getSaveFileName( + filename = QtWidgets.QFileDialog.getSaveFileName( self, _translate("MainWindow", "Save As..."), defaultFilename, - "Text files (*.txt);;All files (*.*)" - ) + "Text files (*.txt);;All files (*.*)")[0] if not filename: return try: @@ -3702,8 +3706,8 @@ class MyForm(settingsmixin.SMainWindow): account = accountClass(myAddress) if isinstance(account, GatewayAccount) \ and otherAddress == account.relayAddress and ( - (currentColumn in (0, 2) and currentFolder == "sent") - or (currentColumn in (1, 2) and currentFolder != "sent")): + (currentColumn in (0, 2) and currentFolder == "sent") or + (currentColumn in (1, 2) and currentFolder != "sent")): text = tableWidget.item(currentRow, currentColumn).label else: text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole) @@ -3764,10 +3768,9 @@ class MyForm(settingsmixin.SMainWindow): current_files += [upper] filters[0:0] = ['Image files (' + ' '.join(all_images_filter) + ')'] filters[1:1] = ['All files (*.*)'] - sourcefile, filetype = QtWidgets.QFileDialog.getOpenFileName( + sourcefile = QtWidgets.QFileDialog.getOpenFileName( self, _translate("MainWindow", "Set avatar..."), - filter=';;'.join(filters) - ) + filter=';;'.join(filters))[0] # determine the correct filename (note that avatars don't use the suffix) destination = state.appdata + 'avatars/' + hash + '.' + sourcefile.split('.')[-1] exists = QtCore.QFile.exists(destination) @@ -3828,10 +3831,10 @@ class MyForm(settingsmixin.SMainWindow): "MainWindow", "Sound files (%s)" % ' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions]) ))] - sourcefile, filetype = QtWidgets.QFileDialog.getOpenFileName( + sourcefile = QtWidgets.QFileDialog.getOpenFileName( self, _translate("MainWindow", "Set notification sound..."), filter=';;'.join(filters) - ) + )[0] if not sourcefile: return @@ -4095,6 +4098,8 @@ class MyForm(settingsmixin.SMainWindow): except NameError: message = u"" except IndexError: + # _translate() often returns unicode, no redefinition here! + # pylint: disable=redefined-variable-type message = _translate( "MainWindow", "Error occurred: could not load message from disk." diff --git a/src/bitmessageqt/address_dialogs.py b/src/bitmessageqt/address_dialogs.py index 87ecb431..ac78d5ea 100644 --- a/src/bitmessageqt/address_dialogs.py +++ b/src/bitmessageqt/address_dialogs.py @@ -91,7 +91,7 @@ class AddressDataDialog(QtWidgets.QDialog, AddressCheckMixin): def __init__(self, parent): super(AddressDataDialog, self).__init__(parent) self.parent = parent - self.data = ("", "") + self.data = None def accept(self): """Callback for QDialog accepting value""" @@ -187,6 +187,7 @@ class NewSubscriptionDialog(AddressDataDialog): def __init__(self, parent=None): super(NewSubscriptionDialog, self).__init__(parent) widgets.load('newsubscriptiondialog.ui', self) + self.recent = [] self._setup() def _onSuccess(self, addressVersion, streamNumber, ripe): @@ -306,6 +307,7 @@ class EmailGatewayDialog(QtWidgets.QDialog): widgets.load('emailgateway.ui', self) self.parent = parent self.config = config + self.data = None if account: self.acct = account self.setWindowTitle(_translate( diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py index a11a4cdb..02f1ad8c 100644 --- a/src/bitmessageqt/bitmessageui.py +++ b/src/bitmessageqt/bitmessageui.py @@ -1,3 +1,6 @@ +# pylint: skip-file +# flake8: noqa + from qtpy import QtCore, QtGui, QtWidgets from tr import _translate from bmconfigparser import BMConfigParser diff --git a/src/depends.py b/src/depends.py index 40bb7ce1..c8134043 100755 --- a/src/depends.py +++ b/src/depends.py @@ -136,17 +136,17 @@ detectOS.result = None def detectOSRelease(): """Detecting the release of OS""" with open("/etc/os-release", 'r') as osRelease: - version = None + ver = None for line in osRelease: if line.startswith("NAME="): detectOS.result = OS_RELEASE.get( line.replace('"', '').split("=")[-1].strip().lower()) elif line.startswith("VERSION_ID="): try: - version = float(line.split("=")[1].replace("\"", "")) + ver = float(line.split("=")[1].replace("\"", "")) except ValueError: pass - if detectOS.result == "Ubuntu" and version < 14: + if detectOS.result == "Ubuntu" and ver < 14: detectOS.result = "Ubuntu 12" @@ -364,8 +364,10 @@ def check_pyqt(): Here we are checking for PyQt4 with its version, as for it require PyQt 4.8 or later. """ + # pylint: disable=no-member qtpy = try_import( - 'qtpy', 'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.') + 'qtpy', + 'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.') if not qtpy: return False diff --git a/src/qidenticon.py b/src/qidenticon.py index 24cd621d..b61f55ff 100644 --- a/src/qidenticon.py +++ b/src/qidenticon.py @@ -128,7 +128,7 @@ class IdenticonRendererBase(object): return image - def decode(self, code): + def decode(self, code, twoColor): """virtual functions""" raise NotImplementedError