Merge branch 'v0.6' into readthedocs

This commit is contained in:
Peter Šurda 2018-06-26 08:50:21 +02:00 committed by GitHub
commit a01d5a378c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 89 deletions

View File

@ -2509,18 +2509,14 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
treeWidget = self.widgetConvert(sent) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent": if self.getCurrentFolder(treeWidget) != "sent":
continue continue
if all( if (
[ treeWidget == self.ui.treeWidgetYourIdentities and
treeWidget == self.ui.treeWidgetYourIdentities, self.getCurrentAccount(treeWidget) not in (fromAddress, None, False)
self.getCurrentAccount(treeWidget) not in (fromAddress, None, False),
]
): ):
continue continue
elif all( elif (
[ treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and
treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans], self.getCurrentAccount(treeWidget) != toAddress
self.getCurrentAccount(treeWidget) != toAddress,
]
): ):
continue continue
elif not helper_search.check_match( elif not helper_search.check_match(
@ -2565,12 +2561,10 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
self.getCurrentSearchLine(tab), self.getCurrentSearchLine(tab),
): ):
continue continue
if all( if (
[ tableWidget == inbox and
tableWidget == inbox, self.getCurrentAccount(treeWidget) == acct.address and
self.getCurrentAccount(treeWidget) == acct.address, self.getCurrentFolder(treeWidget) in ["inbox", None]
self.getCurrentFolder(treeWidget) in ["inbox", None],
]
): ):
ret = self.addMessageListItemInbox( ret = self.addMessageListItemInbox(
inbox, inbox,
@ -2582,12 +2576,10 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
time.time(), time.time(),
0, 0,
) )
elif treeWidget == all( elif (
[ treeWidget == self.ui.treeWidgetYourIdentities and
self.ui.treeWidgetYourIdentities, self.getCurrentAccount(treeWidget) is None and
self.getCurrentAccount(treeWidget) is None, self.getCurrentFolder(treeWidget) in ["inbox", "new", None]
self.getCurrentFolder(treeWidget) in ["inbox", "new", None]
]
): ):
ret = self.addMessageListItemInbox( ret = self.addMessageListItemInbox(
tableWidget, tableWidget,
@ -2612,17 +2604,12 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
unicode(acct.fromLabel, 'utf-8')), unicode(acct.fromLabel, 'utf-8')),
sound.SOUND_UNKNOWN sound.SOUND_UNKNOWN
) )
if any( # pylint: disable=undefined-loop-variable
[ if (
all( self.getCurrentAccount() is not None and (
[ self.getCurrentFolder(treeWidget) not in ("inbox", None) or
self.getCurrentAccount() is not None, self.getCurrentAccount(treeWidget) != acct.address
self.getCurrentFolder(treeWidget) != "inbox", # pylint: disable=undefined-loop-variable )
self.getCurrentFolder(treeWidget) is not None, # pylint: disable=undefined-loop-variable
]
),
self.getCurrentAccount(treeWidget) != acct.address # pylint: disable=undefined-loop-variable
]
): ):
# Ubuntu should notify of new message irespective of # Ubuntu should notify of new message irespective of
# whether it's in current message list or not # whether it's in current message list or not
@ -2632,6 +2619,7 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if acct.feedback == GatewayAccount.REGISTRATION_DENIED: if acct.feedback == GatewayAccount.REGISTRATION_DENIED:
dialogs.EmailGatewayDialog( dialogs.EmailGatewayDialog(
self, BMConfigParser(), acct).exec_() self, BMConfigParser(), acct).exec_()
# pylint: enable=undefined-loop-variable
def click_pushButtonAddAddressBook(self, dialog=None): def click_pushButtonAddAddressBook(self, dialog=None):
"""TBC""" """TBC"""
@ -2789,13 +2777,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
upnpThread = upnp.uPnPThread() upnpThread = upnp.uPnPThread()
upnpThread.start() upnpThread.start()
if all( if (
[ BMConfigParser().get('bitmessagesettings', 'socksproxytype') == 'none' and
BMConfigParser().get( self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS'
'bitmessagesettings',
'socksproxytype') == 'none',
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS',
]
): ):
if shared.statusIconColor != 'red': if shared.statusIconColor != 'red':
QtGui.QMessageBox.about( QtGui.QMessageBox.about(
@ -2808,11 +2792,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
("Bitmessage will use your proxy from now on but you may want to manually restart " ("Bitmessage will use your proxy from now on but you may want to manually restart "
"Bitmessage now to close existing connections (if any)."))) "Bitmessage now to close existing connections (if any).")))
if all( if (
[ BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and
BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS', self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS'
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS',
]
): ):
self.statusbar.clearMessage() self.statusbar.clearMessage()
state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity
@ -2879,11 +2861,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
acceptableDifficultyChanged = False acceptableDifficultyChanged = False
if any( if (
[ float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1, float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0,
]
): ):
if BMConfigParser().get( if BMConfigParser().get(
'bitmessagesettings', 'bitmessagesettings',
@ -2901,11 +2881,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text() self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte))) ) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
if any( if (
[ float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1, float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0
float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0,
]
): ):
if BMConfigParser().get( if BMConfigParser().get(
'bitmessagesettings', 'bitmessagesettings',
@ -2932,11 +2910,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
# start:UI setting to stop trying to send messages after X days/months # start:UI setting to stop trying to send messages after X days/months
# I'm open to changing this UI to something else if someone has a better idea. # I'm open to changing this UI to something else if someone has a better idea.
if all( if (
[ self.settingsDialogInstance.ui.lineEditDays.text() == '' and
self.settingsDialogInstance.ui.lineEditDays.text() == '', self.settingsDialogInstance.ui.lineEditMonths.text() == ''
self.settingsDialogInstance.ui.lineEditMonths.text() == '',
]
): # We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank ): # We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '') BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '')
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '') BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '')
@ -2956,11 +2932,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if lineEditMonthsIsValidFloat and not lineEditDaysIsValidFloat: if lineEditMonthsIsValidFloat and not lineEditDaysIsValidFloat:
self.settingsDialogInstance.ui.lineEditDays.setText("0") self.settingsDialogInstance.ui.lineEditDays.setText("0")
if lineEditDaysIsValidFloat or lineEditMonthsIsValidFloat: if lineEditDaysIsValidFloat or lineEditMonthsIsValidFloat:
if all( if (
[ float(self.settingsDialogInstance.ui.lineEditDays.text()) >= 0 and
float(self.settingsDialogInstance.ui.lineEditDays.text()) >= 0, float(self.settingsDialogInstance.ui.lineEditMonths.text()) >= 0
float(self.settingsDialogInstance.ui.lineEditMonths.text()) >= 0,
]
): ):
shared.maximumLengthOfTimeToBotherResendingMessages = sum( shared.maximumLengthOfTimeToBotherResendingMessages = sum(
float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60, float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60,
@ -4273,6 +4247,7 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
def on_action_ClipboardMessagelist(self): def on_action_ClipboardMessagelist(self):
"""TBC""" """TBC"""
# pylint: disable=too-many-boolean-expressions
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
currentColumn = tableWidget.currentColumn() currentColumn = tableWidget.currentColumn()
@ -4289,17 +4264,12 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
myAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole) myAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
otherAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole) otherAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
account = accountClass(myAddress) account = accountClass(myAddress)
if all( if (
[ isinstance(account, GatewayAccount) and
isinstance(account, GatewayAccount), otherAddress == account.relayAddress and (
otherAddress == account.relayAddress, currentColumn in [0, 2] and self.getCurrentFolder() == "sent" or
any( currentColumn in [1, 2] and self.getCurrentFolder() != "sent"
[ )
currentColumn in [0, 2] and self.getCurrentFolder() == "sent",
currentColumn in [1, 2] and self.getCurrentFolder() != "sent",
]
),
]
): ):
text = str(tableWidget.item(currentRow, currentColumn).label) text = str(tableWidget.item(currentRow, currentColumn).label)
@ -4644,12 +4614,10 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if column != 0: if column != 0:
return return
# only account names of normal addresses (no chans/mailinglists) # only account names of normal addresses (no chans/mailinglists)
if any( if (
[ not isinstance(item, Ui_AddressWidget) or
not isinstance(item, Ui_AddressWidget), not self.getCurrentTreeWidget() or
not self.getCurrentTreeWidget(), self.getCurrentTreeWidget().currentItem() is None
self.getCurrentTreeWidget().currentItem() is None,
]
): ):
return return
@ -4719,11 +4687,9 @@ class MyForm(settingsmixin.SMainWindow): # pylint: disable=too-many-public-meth
if tableWidget.item(currentRow, 0).unread is True: if tableWidget.item(currentRow, 0).unread is True:
self.updateUnreadStatus(tableWidget, currentRow, msgid) self.updateUnreadStatus(tableWidget, currentRow, msgid)
# propagate # propagate
if all( if (
[ folder != 'sent' and
folder != 'sent', sqlExecute('''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''', msgid) > 0
sqlExecute('''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''', msgid) > 0,
]
): ):
self.propagateUnreadCount() self.propagateUnreadCount()

View File

@ -300,7 +300,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
def _command_inv(self, dandelion=False): def _command_inv(self, dandelion=False):
items = self.decode_payload_content("l32s") items = self.decode_payload_content("l32s")
if len(items) >= BMProto.maxObjectCount: if len(items) > BMProto.maxObjectCount:
logger.error("Too many items in %sinv message!", "d" if dandelion else "") logger.error("Too many items in %sinv message!", "d" if dandelion else "")
raise BMProtoExcessiveDataError() raise BMProtoExcessiveDataError()
else: else:

View File

@ -180,7 +180,11 @@ class TCPConnection(BMProto, TLSDispatcher):
for hash, storedValue in bigInvList.items(): for hash, storedValue in bigInvList.items():
payload += hash payload += hash
objectCount += 1 objectCount += 1
if objectCount >= BMProto.maxObjectCount:
# Remove -1 below when sufficient time has passed for users to
# upgrade to versions of PyBitmessage that accept inv with 50,000
# items
if objectCount >= BMProto.maxObjectCount - 1:
sendChunk() sendChunk()
payload = b'' payload = b''
objectCount = 0 objectCount = 0