Changes based on style and lint checks. (final_code_quality_7) #1365
|
@ -1,17 +1,22 @@
|
||||||
PeterSurda
commented
Review
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
PeterSurda
commented
Review
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
src/bitmessageqt/messageview.py
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
===============================
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import multiprocessing
|
from safehtmlparser import SafeHTMLParser
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
import Queue
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
from urlparse import urlparse
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
from safehtmlparser import *
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
|
||||||
class MessageView(QtGui.QTextBrowser):
|
class MessageView(QtGui.QTextBrowser):
|
||||||
|
"""Message content viewer class, can switch between plaintext and HTML"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
MODE_PLAIN = 0
|
MODE_PLAIN = 0
|
||||||
MODE_HTML = 1
|
MODE_HTML = 1
|
||||||
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
def __init__(self, parent = 0):
|
def __init__(self, parent=0):
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
super(MessageView, self).__init__(parent)
|
super(MessageView, self).__init__(parent)
|
||||||
self.mode = MessageView.MODE_PLAIN
|
self.mode = MessageView.MODE_PLAIN
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.html = None
|
self.html = None
|
||||||
self.setOpenExternalLinks(False)
|
self.setOpenExternalLinks(False)
|
||||||
self.setOpenLinks(False)
|
self.setOpenLinks(False)
|
||||||
|
@ -25,12 +30,14 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.setWrappingWidth()
|
self.setWrappingWidth()
|
||||||
|
|
||||||
def resizeEvent(self, event):
|
def resizeEvent(self, event):
|
||||||
|
"""View resize event handler"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
super(MessageView, self).resizeEvent(event)
|
super(MessageView, self).resizeEvent(event)
|
||||||
self.setWrappingWidth(event.size().width())
|
self.setWrappingWidth(event.size().width())
|
||||||
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
#text = textCursor.block().text()
|
"""Mouse press button event handler"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
if event.button() == QtCore.Qt.LeftButton and self.html and self.html.has_html and self.cursorForPosition(event.pos()).block().blockNumber() == 0:
|
if event.button() == QtCore.Qt.LeftButton and self.html and self.html.has_html and self.cursorForPosition(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
event.pos()).block().blockNumber() == 0:
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
if self.mode == MessageView.MODE_PLAIN:
|
if self.mode == MessageView.MODE_PLAIN:
|
||||||
self.showHTML()
|
self.showHTML()
|
||||||
else:
|
else:
|
||||||
|
@ -39,19 +46,24 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
super(MessageView, self).mousePressEvent(event)
|
super(MessageView, self).mousePressEvent(event)
|
||||||
|
|
||||||
def wheelEvent(self, event):
|
def wheelEvent(self, event):
|
||||||
|
"""Mouse wheel scroll event handler"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# super will actually automatically take care of zooming
|
# super will actually automatically take care of zooming
|
||||||
super(MessageView, self).wheelEvent(event)
|
super(MessageView, self).wheelEvent(event)
|
||||||
if (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
if (QtGui.QApplication.queryKeyboardModifiers() &
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
|
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
|
||||||
QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom)))
|
QtGui.QApplication.activeWindow().statusBar().showMessage(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom)))
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
|
||||||
def setWrappingWidth(self, width=None):
|
def setWrappingWidth(self, width=None):
|
||||||
|
"""Set word-wrapping width"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.setLineWrapMode(QtGui.QTextEdit.FixedPixelWidth)
|
self.setLineWrapMode(QtGui.QTextEdit.FixedPixelWidth)
|
||||||
if width is None:
|
if width is None:
|
||||||
width = self.width()
|
width = self.width()
|
||||||
self.setLineWrapColumnOrWidth(width)
|
self.setLineWrapColumnOrWidth(width)
|
||||||
|
|
||||||
def confirmURL(self, link):
|
def confirmURL(self, link):
|
||||||
|
"""Show a dialog requesting URL opening confirmation"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
if link.scheme() == "mailto":
|
if link.scheme() == "mailto":
|
||||||
window = QtGui.QApplication.activeWindow()
|
window = QtGui.QApplication.activeWindow()
|
||||||
window.ui.lineEditTo.setText(link.path())
|
window.ui.lineEditTo.setText(link.path())
|
||||||
|
@ -68,35 +80,39 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
)
|
)
|
||||||
window.ui.textEditMessage.setFocus()
|
window.ui.textEditMessage.setFocus()
|
||||||
return
|
return
|
||||||
reply = QtGui.QMessageBox.warning(self,
|
reply = QtGui.QMessageBox.warning(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
QtGui.QApplication.translate("MessageView", "Follow external link"),
|
self,
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
QtGui.QApplication.translate("MessageView", "The link \"%1\" will open in a browser. It may be a security risk, it could de-anonymise you or download malicious data. Are you sure?").arg(unicode(link.toString())),
|
QtGui.QApplication.translate(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
"MessageView",
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"Follow external link"),
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtGui.QApplication.translate(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"MessageView",
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"The link \"%1\" will open in a browser. It may be a security risk, it could de-anonymise you"
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
" or download malicious data. Are you sure?").arg(unicode(link.toString())),
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtGui.QMessageBox.Yes,
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtGui.QMessageBox.No)
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
if reply == QtGui.QMessageBox.Yes:
|
if reply == QtGui.QMessageBox.Yes:
|
||||||
QtGui.QDesktopServices.openUrl(link)
|
QtGui.QDesktopServices.openUrl(link)
|
||||||
|
|
||||||
def loadResource (self, restype, name):
|
def loadResource(self, restype, name):
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
if restype == QtGui.QTextDocument.ImageResource and name.scheme() == "bmmsg":
|
"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
pass
|
Callback for loading referenced objects, such as an image. For security reasons at the moment doesn't do
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# QImage correctImage;
|
anything)
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# lookup the correct QImage from a cache
|
"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# return QVariant::fromValue(correctImage);
|
pass
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# elif restype == QtGui.QTextDocument.HtmlResource:
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# elif restype == QtGui.QTextDocument.ImageResource:
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# elif restype == QtGui.QTextDocument.StyleSheetResource:
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# elif restype == QtGui.QTextDocument.UserResource:
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
else:
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
pass
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# by default, this will interpret it as a local file
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
# QtGui.QTextBrowser.loadResource(restype, name)
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
|
||||||
def lazyRender(self):
|
def lazyRender(self):
|
||||||
|
"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
Partially render a message. This is to avoid UI freezing when loading huge messages. It continues loading as
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
you scroll down.
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
if self.rendering:
|
if self.rendering:
|
||||||
return
|
return
|
||||||
self.rendering = True
|
self.rendering = True
|
||||||
position = self.verticalScrollBar().value()
|
position = self.verticalScrollBar().value()
|
||||||
cursor = QtGui.QTextCursor(self.document())
|
cursor = QtGui.QTextCursor(self.document())
|
||||||
while self.outpos < len(self.out) and self.verticalScrollBar().value() >= self.document().size().height() - 2 * self.size().height():
|
while self.outpos < len(self.out) and self.verticalScrollBar().value(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
) >= self.document().size().height() - 2 * self.size().height():
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
startpos = self.outpos
|
startpos = self.outpos
|
||||||
self.outpos += 10240
|
self.outpos += 10240
|
||||||
```suggestion
"""Render message as plain text."""
```
```suggestion
"""Render message as HTML"""
```
```suggestion
"""Set message content from argument"""
```
|
|||||||
# find next end of tag
|
# find next end of tag
|
||||||
|
@ -108,27 +124,33 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
cursor.insertHtml(QtCore.QString(self.out[startpos:self.outpos]))
|
cursor.insertHtml(QtCore.QString(self.out[startpos:self.outpos]))
|
||||||
self.verticalScrollBar().setValue(position)
|
self.verticalScrollBar().setValue(position)
|
||||||
self.rendering = False
|
self.rendering = False
|
||||||
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
def showPlain(self):
|
def showPlain(self):
|
||||||
|
"""Render message as plain text."""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.mode = MessageView.MODE_PLAIN
|
self.mode = MessageView.MODE_PLAIN
|
||||||
out = self.html.raw
|
out = self.html.raw
|
||||||
if self.html.has_html:
|
if self.html.has_html:
|
||||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(QtGui.QApplication.translate("MessageView", "HTML detected, click here to display")) + "</b></div><br/>" + out
|
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtGui.QApplication.translate(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
"MessageView", "HTML detected, click here to display")) + "</b></div><br/>" + out
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.out = out
|
self.out = out
|
||||||
self.outpos = 0
|
self.outpos = 0
|
||||||
self.setHtml("")
|
self.setHtml("")
|
||||||
self.lazyRender()
|
self.lazyRender()
|
||||||
|
|
||||||
def showHTML(self):
|
def showHTML(self):
|
||||||
|
"""Render message as HTML"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.mode = MessageView.MODE_HTML
|
self.mode = MessageView.MODE_HTML
|
||||||
out = self.html.sanitised
|
out = self.html.sanitised
|
||||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(QtGui.QApplication.translate("MessageView", "Click here to disable HTML")) + "</b></div><br/>" + out
|
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
|
QtGui.QApplication.translate("MessageView", "Click here to disable HTML")) + "</b></div><br/>" + out
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.out = out
|
self.out = out
|
||||||
self.outpos = 0
|
self.outpos = 0
|
||||||
self.setHtml("")
|
self.setHtml("")
|
||||||
self.lazyRender()
|
self.lazyRender()
|
||||||
|
|
||||||
def setContent(self, data):
|
def setContent(self, data):
|
||||||
|
"""Set message content from argument"""
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|||||||
self.html = SafeHTMLParser()
|
self.html = SafeHTMLParser()
|
||||||
self.html.reset()
|
self.html.reset()
|
||||||
self.html.reset_safe()
|
self.html.reset_safe()
|
||||||
|
|
||||||
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
```suggestion
"""Message content viewer class, can switch between plaintext and HTML"""
```
|
|
@ -1,20 +1,27 @@
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
from PyQt4 import QtCore, QtGui
|
"""
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
import time
|
src/bitmessageqt/networkstatus.py
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
import shared
|
=================================
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
import time
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
from tr import _translate
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
from inventory import Inventory
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
import knownnodes
|
import knownnodes
|
||||||
import l10n
|
import l10n
|
||||||
import network.stats
|
import network.stats
|
||||||
from retranslateui import RetranslateMixin
|
import shared
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
from uisignaler import UISignaler
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
import widgets
|
import widgets
|
||||||
|
from inventory import Inventory
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
from network.connectionpool import BMConnectionPool
|
from network.connectionpool import BMConnectionPool
|
||||||
|
from retranslateui import RetranslateMixin
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
from tr import _translate
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
from uisignaler import UISignaler
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
|
|
||||||
class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
|
"""Network status tab"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(NetworkStatus, self).__init__(parent)
|
super(NetworkStatus, self).__init__(parent)
|
||||||
widgets.load('networkstatus.ui', self)
|
widgets.load('networkstatus.ui', self)
|
||||||
|
@ -29,8 +36,9 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.startup = time.localtime()
|
self.startup = time.localtime()
|
||||||
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
|
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
|
||||||
l10n.formatTimestamp(self.startup)))
|
l10n.formatTimestamp(self.startup)))
|
||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.UISignalThread = UISignaler.get()
|
self.UISignalThread = UISignaler.get()
|
||||||
|
# pylint: disable=no-member
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"updateNumberOfMessagesProcessed()"), self.updateNumberOfMessagesProcessed)
|
"updateNumberOfMessagesProcessed()"), self.updateNumberOfMessagesProcessed)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
|
@ -42,57 +50,108 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
self.timer = QtCore.QTimer()
|
self.timer = QtCore.QTimer()
|
||||||
|
|
||||||
QtCore.QObject.connect(
|
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
|
# pylint: enable=no-member
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
def startUpdate(self):
|
def startUpdate(self):
|
||||||
|
"""Start a timer to update counters every 2 seconds"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
Inventory().numberOfInventoryLookupsPerformed = 0
|
Inventory().numberOfInventoryLookupsPerformed = 0
|
||||||
self.runEveryTwoSeconds()
|
self.runEveryTwoSeconds()
|
||||||
self.timer.start(2000) # milliseconds
|
self.timer.start(2000) # milliseconds
|
||||||
|
|
||||||
def stopUpdate(self):
|
def stopUpdate(self):
|
||||||
|
"""Stop counter update timer"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
self.timer.stop()
|
self.timer.stop()
|
||||||
|
|
||||||
def formatBytes(self, num):
|
def formatBytes(self, num):
|
||||||
for x in [_translate("networkstatus", "byte(s)", None, QtCore.QCoreApplication.CodecForTr, num), "kB", "MB", "GB"]:
|
"""Format bytes nicely (SI prefixes)"""
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
# pylint: disable=no-self-use
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
for x in [
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"networkstatus",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"byte(s)",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
None,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
QtCore.QCoreApplication.CodecForTr,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
num),
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"kB",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"MB",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"GB",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
]:
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
if num < 1000.0:
|
if num < 1000.0:
|
||||||
return "%3.0f %s" % (num, x)
|
return "%3.0f %s" % (num, x)
|
||||||
num /= 1000.0
|
num /= 1000.0
|
||||||
return "%3.0f %s" % (num, 'TB')
|
return "%3.0f %s" % (num, 'TB')
|
||||||
|
|
||||||
def formatByteRate(self, num):
|
def formatByteRate(self, num):
|
||||||
|
"""Format transfer speed in kB/s"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
# pylint: disable=no-self-use
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
num /= 1000
|
num /= 1000
|
||||||
return "%4.0f kB" % num
|
return "%4.0f kB" % num
|
||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
def updateNumberOfObjectsToBeSynced(self):
|
def updateNumberOfObjectsToBeSynced(self):
|
||||||
self.labelSyncStatus.setText(_translate("networkstatus", "Object(s) to be synced: %n", None, QtCore.QCoreApplication.CodecForTr, network.stats.pendingDownload() + network.stats.pendingUpload()))
|
"""Update the counter for number of objects to be synced"""
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
self.labelSyncStatus.setText(
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"networkstatus",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"Object(s) to be synced: %n",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
None,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
QtCore.QCoreApplication.CodecForTr,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
network.stats.pendingDownload() +
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
network.stats.pendingUpload()))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
def updateNumberOfMessagesProcessed(self):
|
def updateNumberOfMessagesProcessed(self):
|
||||||
|
"""Update the counter for number of processed messages"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
self.updateNumberOfObjectsToBeSynced()
|
self.updateNumberOfObjectsToBeSynced()
|
||||||
self.labelMessageCount.setText(_translate(
|
self.labelMessageCount.setText(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Processed %n person-to-person message(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfMessagesProcessed))
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
"networkstatus",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"Processed %n person-to-person message(s).",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
None,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
QtCore.QCoreApplication.CodecForTr,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
shared.numberOfMessagesProcessed))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
def updateNumberOfBroadcastsProcessed(self):
|
def updateNumberOfBroadcastsProcessed(self):
|
||||||
|
"""Update the counter for the number of processed broadcasts"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
self.updateNumberOfObjectsToBeSynced()
|
self.updateNumberOfObjectsToBeSynced()
|
||||||
self.labelBroadcastCount.setText(_translate(
|
self.labelBroadcastCount.setText(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Processed %n broadcast message(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfBroadcastsProcessed))
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
"networkstatus",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"Processed %n broadcast message(s).",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
None,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
QtCore.QCoreApplication.CodecForTr,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
shared.numberOfBroadcastsProcessed))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
def updateNumberOfPubkeysProcessed(self):
|
def updateNumberOfPubkeysProcessed(self):
|
||||||
|
"""Update the counter for the number of processed pubkeys"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
self.updateNumberOfObjectsToBeSynced()
|
self.updateNumberOfObjectsToBeSynced()
|
||||||
self.labelPubkeyCount.setText(_translate(
|
self.labelPubkeyCount.setText(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Processed %n public key(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfPubkeysProcessed))
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
"networkstatus",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"Processed %n public key(s).",
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
None,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
QtCore.QCoreApplication.CodecForTr,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
shared.numberOfPubkeysProcessed))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
def updateNumberOfBytes(self):
|
def updateNumberOfBytes(self):
|
||||||
"""
|
"""
|
||||||
This function is run every two seconds, so we divide the rate of bytes
|
This function is run every two seconds, so we divide the rate of bytes
|
||||||
sent and received by 2.
|
sent and received by 2.
|
||||||
"""
|
"""
|
||||||
self.labelBytesRecvCount.setText(_translate(
|
self.labelBytesRecvCount.setText(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Down: %1/s Total: %2").arg(self.formatByteRate(network.stats.downloadSpeed()), self.formatBytes(network.stats.receivedBytes())))
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.labelBytesSentCount.setText(_translate(
|
"networkstatus",
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Up: %1/s Total: %2").arg(self.formatByteRate(network.stats.uploadSpeed()), self.formatBytes(network.stats.sentBytes())))
|
"Down: %1/s Total: %2").arg(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
self.formatByteRate(network.stats.downloadSpeed()),
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
self.formatBytes(network.stats.receivedBytes())))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
self.labelBytesSentCount.setText(
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
"networkstatus", "Up: %1/s Total: %2").arg(
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
self.formatByteRate(network.stats.uploadSpeed()),
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
self.formatBytes(network.stats.sentBytes())))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
def updateNetworkStatusTab(self, outbound, add, destination):
|
def updateNetworkStatusTab(self, outbound, add, destination):
|
||||||
|
"""Add or remove an entry to the list of connected peers"""
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
# pylint: disable=too-many-branches,undefined-variable
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
if outbound:
|
if outbound:
|
||||||
try:
|
try:
|
||||||
c = BMConnectionPool().outboundConnections[destination]
|
c = BMConnectionPool().outboundConnections[destination]
|
||||||
|
@ -111,33 +170,39 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
self.tableWidgetConnectionCount.setUpdatesEnabled(False)
|
self.tableWidgetConnectionCount.setUpdatesEnabled(False)
|
||||||
self.tableWidgetConnectionCount.setSortingEnabled(False)
|
self.tableWidgetConnectionCount.setSortingEnabled(False)
|
||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
if add:
|
if add:
|
||||||
self.tableWidgetConnectionCount.insertRow(0)
|
self.tableWidgetConnectionCount.insertRow(0)
|
||||||
self.tableWidgetConnectionCount.setItem(0, 0,
|
self.tableWidgetConnectionCount.setItem(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
0, 0,
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Updates counters, runs every 2 seconds if the timer is running"""
```
|
|||||||
QtGui.QTableWidgetItem("%s:%i" % (destination.host, destination.port))
|
QtGui.QTableWidgetItem("%s:%i" % (destination.host, destination.port))
|
||||||
)
|
)
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.tableWidgetConnectionCount.setItem(0, 2,
|
self.tableWidgetConnectionCount.setItem(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
0, 2,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
QtGui.QTableWidgetItem("%s" % (c.userAgent))
|
QtGui.QTableWidgetItem("%s" % (c.userAgent))
|
||||||
)
|
)
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.tableWidgetConnectionCount.setItem(0, 3,
|
self.tableWidgetConnectionCount.setItem(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
0, 3,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
QtGui.QTableWidgetItem("%s" % (c.tlsVersion))
|
QtGui.QTableWidgetItem("%s" % (c.tlsVersion))
|
||||||
)
|
)
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.tableWidgetConnectionCount.setItem(0, 4,
|
self.tableWidgetConnectionCount.setItem(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
QtGui.QTableWidgetItem("%s" % (",".join(map(str,c.streams))))
|
0, 4,
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
)
|
QtGui.QTableWidgetItem("%s" % (",".join(map(str, c.streams))))
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
try:
|
try:
|
||||||
# FIXME hard coded stream no
|
# .. todo:: FIXME: hard coded stream no
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
rating = "%.1f" % (knownnodes.knownNodes[1][destination]['rating'])
|
rating = "%.1f" % (knownnodes.knownNodes[1][destination]['rating'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
rating = "-"
|
rating = "-"
|
||||||
self.tableWidgetConnectionCount.setItem(0, 1,
|
self.tableWidgetConnectionCount.setItem(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
0, 1,
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
QtGui.QTableWidgetItem("%s" % (rating))
|
QtGui.QTableWidgetItem("%s" % (rating))
|
||||||
)
|
)
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
if outbound:
|
if outbound:
|
||||||
brush = QtGui.QBrush(QtGui.QColor("yellow"), QtCore.Qt.SolidPattern)
|
brush = QtGui.QBrush(QtGui.QColor("yellow"), QtCore.Qt.SolidPattern)
|
||||||
else:
|
else:
|
||||||
brush = QtGui.QBrush(QtGui.QColor("green"), QtCore.Qt.SolidPattern)
|
brush = QtGui.QBrush(QtGui.QColor("green"), QtCore.Qt.SolidPattern)
|
||||||
for j in (range(1)):
|
for j in range(1):
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
self.tableWidgetConnectionCount.item(0, j).setBackground(brush)
|
self.tableWidgetConnectionCount.item(0, j).setBackground(brush)
|
||||||
self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.UserRole, destination)
|
self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.UserRole, destination)
|
||||||
self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.UserRole, outbound)
|
self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.UserRole, outbound)
|
||||||
|
@ -148,11 +213,16 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.UserRole).toPyObject() == outbound:
|
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.UserRole).toPyObject() == outbound:
|
||||||
self.tableWidgetConnectionCount.removeRow(i)
|
self.tableWidgetConnectionCount.removeRow(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
self.tableWidgetConnectionCount.setUpdatesEnabled(True)
|
self.tableWidgetConnectionCount.setUpdatesEnabled(True)
|
||||||
self.tableWidgetConnectionCount.setSortingEnabled(True)
|
self.tableWidgetConnectionCount.setSortingEnabled(True)
|
||||||
self.labelTotalConnections.setText(_translate(
|
self.labelTotalConnections.setText(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Total Connections: %1").arg(str(self.tableWidgetConnectionCount.rowCount())))
|
_translate(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
# FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly.
|
"networkstatus", "Total Connections: %1").arg(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
str(self.tableWidgetConnectionCount.rowCount())))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
# FYI: The 'singlelistener' thread sets the icon color to green when it
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
# receives an incoming connection, meaning that the user's firewall is
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
|
# configured correctly.
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
if self.tableWidgetConnectionCount.rowCount() and shared.statusIconColor == 'red':
|
if self.tableWidgetConnectionCount.rowCount() and shared.statusIconColor == 'red':
|
||||||
self.window().setStatusIcon('yellow')
|
self.window().setStatusIcon('yellow')
|
||||||
elif self.tableWidgetConnectionCount.rowCount() == 0 and shared.statusIconColor != "red":
|
elif self.tableWidgetConnectionCount.rowCount() == 0 and shared.statusIconColor != "red":
|
||||||
|
@ -160,8 +230,9 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
|
||||||
# timer driven
|
# timer driven
|
||||||
def runEveryTwoSeconds(self):
|
def runEveryTwoSeconds(self):
|
||||||
self.labelLookupsPerSecond.setText(_translate(
|
"""Updates counters, runs every 2 seconds if the timer is running"""
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
"networkstatus", "Inventory lookups per second: %1").arg(str(Inventory().numberOfInventoryLookupsPerformed/2)))
|
self.labelLookupsPerSecond.setText(_translate("networkstatus", "Inventory lookups per second: %1").arg(
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|||||||
|
str(Inventory().numberOfInventoryLookupsPerformed / 2)))
|
||||||
```suggestion
"""Network status tab"""
```
|
|||||||
Inventory().numberOfInventoryLookupsPerformed = 0
|
Inventory().numberOfInventoryLookupsPerformed = 0
|
||||||
self.updateNumberOfBytes()
|
self.updateNumberOfBytes()
|
||||||
self.updateNumberOfObjectsToBeSynced()
|
self.updateNumberOfObjectsToBeSynced()
|
||||||
|
|
||||||
```suggestion
"""Network status tab"""
```
```suggestion
"""Network status tab"""
```
|
|
@ -1,40 +1,41 @@
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
src/class_singleWorker.py
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
=========================
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
# pylint: disable=protected-access,too-many-branches,too-many-statements,no-self-use,too-many-lines,too-many-locals
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
import time
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import threading
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import hashlib
|
import hashlib
|
||||||
from struct import pack
|
import threading
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# used when the API must execute an outside program
|
import time
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
from subprocess import call # nosec
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
|
from struct import pack
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
from subprocess import call # nosec
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
import tr
|
import defaults
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
import helper_inbox
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
import helper_msgcoding
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
import helper_random
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
import highlevelcrypto
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import l10n
|
import l10n
|
||||||
|
import proofofwork
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import protocol
|
import protocol
|
||||||
import queues
|
import queues
|
||||||
import state
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import shared
|
import shared
|
||||||
import defaults
|
import state
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import highlevelcrypto
|
import tr
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import proofofwork
|
from addresses import calculateInventoryHash, decodeAddress, decodeVarint, encodeVarint
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import helper_inbox
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import helper_random
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
import helper_msgcoding
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from inventory import Inventory
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
from addresses import (
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
decodeAddress, encodeVarint, decodeVarint, calculateInventoryHash
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# from helper_generic import addDataPadding
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
from helper_threading import StoppableThread
|
from helper_threading import StoppableThread
|
||||||
from helper_sql import sqlQuery, sqlExecute
|
from inventory import Inventory
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
|
|
||||||
# This thread, of which there is only one, does the heavy lifting:
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# calculating POWs.
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
def sizeof_fmt(num, suffix='h/s'):
|
def sizeof_fmt(num, suffix='h/s'):
|
||||||
|
"""Format hashes per seconds nicely (SI prefix)"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
for unit in ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']:
|
for unit in ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']:
|
||||||
if abs(num) < 1000.0:
|
if abs(num) < 1000.0:
|
||||||
return "%3.1f%s%s" % (num, unit, suffix)
|
return "%3.1f%s%s" % (num, unit, suffix)
|
||||||
|
@ -43,14 +44,16 @@ def sizeof_fmt(num, suffix='h/s'):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
|
|
||||||
class singleWorker(threading.Thread, StoppableThread):
|
class singleWorker(threading.Thread, StoppableThread):
|
||||||
|
"""Thread for performing PoW"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# QThread.__init__(self, parent)
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
threading.Thread.__init__(self, name="singleWorker")
|
threading.Thread.__init__(self, name="singleWorker")
|
||||||
self.initStop()
|
self.initStop()
|
||||||
proofofwork.init()
|
proofofwork.init()
|
||||||
|
|
||||||
def stopThread(self):
|
def stopThread(self):
|
||||||
|
"""Signal through the queue that the thread should be stopped"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
try:
|
try:
|
||||||
queues.workerQueue.put(("stopThread", "data"))
|
queues.workerQueue.put(("stopThread", "data"))
|
||||||
except:
|
except:
|
||||||
|
@ -58,6 +61,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
super(singleWorker, self).stopThread()
|
super(singleWorker, self).stopThread()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
while not state.sqlReady and state.shutdown == 0:
|
while not state.sqlReady and state.shutdown == 0:
|
||||||
self.stop.wait(2)
|
self.stop.wait(2)
|
||||||
|
@ -96,12 +100,12 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'''SELECT ackdata FROM sent WHERE status = 'msgsent' ''')
|
'''SELECT ackdata FROM sent WHERE status = 'msgsent' ''')
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
ackdata, = row
|
ackdata, = row
|
||||||
logger.info('Watching for ackdata ' + hexlify(ackdata))
|
logger.info('Watching for ackdata %s', hexlify(ackdata))
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
shared.ackdataForWhichImWatching[ackdata] = 0
|
shared.ackdataForWhichImWatching[ackdata] = 0
|
||||||
|
|
||||||
# Fix legacy (headerless) watched ackdata to include header
|
# Fix legacy (headerless) watched ackdata to include header
|
||||||
for oldack in shared.ackdataForWhichImWatching.keys():
|
for oldack in shared.ackdataForWhichImWatching:
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
if (len(oldack) == 32):
|
if len(oldack) == 32:
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# attach legacy header, always constant (msg/1/1)
|
# attach legacy header, always constant (msg/1/1)
|
||||||
newack = '\x00\x00\x00\x02\x01\x01' + oldack
|
newack = '\x00\x00\x00\x02\x01\x01' + oldack
|
||||||
shared.ackdataForWhichImWatching[newack] = 0
|
shared.ackdataForWhichImWatching[newack] = 0
|
||||||
|
@ -226,19 +230,9 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# inventoryHash = calculateInventoryHash(payload)
|
# inventoryHash = calculateInventoryHash(payload)
|
||||||
The docstring is above the method in a comment. The docstring is above the method in a comment.
|
|||||||
return payload
|
return payload
|
||||||
|
|
||||||
# This function also broadcasts out the pubkey message
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# once it is done with the POW
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
def doPOWForMyV2Pubkey(self, adressHash):
|
def doPOWForMyV2Pubkey(self, adressHash):
|
||||||
|
""" This function also broadcasts out the pubkey message once it is done with the POW"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# Look up my stream number based on my address hash
|
# Look up my stream number based on my address hash
|
||||||
"""configSections = shared.config.addresses()
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
for addressInKeysFile in configSections:
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
if addressInKeysFile != 'bitmessagesettings':
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
status, addressVersionNumber, streamNumber, \
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
hashFromThisParticularAddress = \
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
decodeAddress(addressInKeysFile)
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
if hash == hashFromThisParticularAddress:
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
myAddress = addressInKeysFile
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
break"""
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
myAddress = shared.myAddressesByHash[adressHash]
|
myAddress = shared.myAddressesByHash[adressHash]
|
||||||
# status
|
# status
|
||||||
_, addressVersionNumber, streamNumber, adressHash = decodeAddress(myAddress)
|
_, addressVersionNumber, streamNumber, adressHash = decodeAddress(myAddress)
|
||||||
|
@ -289,11 +283,12 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# before this finished.
|
# before this finished.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# If this isn't a chan address, this function assembles the pubkey data,
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# does the necessary POW and sends it out. If it *is* a chan then it
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# assembles the pubkey and stores is in the pubkey table so that we can
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# send messages to "ourselves".
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
def sendOutOrStoreMyV3Pubkey(self, adressHash):
|
def sendOutOrStoreMyV3Pubkey(self, adressHash):
|
||||||
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
The docstring is before the method as a comment. The docstring is before the method as a comment.
|
|||||||
|
If this isn't a chan address, this function assembles the pubkey data, does the necessary POW and sends it out.
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
If it *is* a chan then it assembles the pubkey and stores is in the pubkey table so that we can send messages
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
to "ourselves".
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
try:
|
try:
|
||||||
myAddress = shared.myAddressesByHash[adressHash]
|
myAddress = shared.myAddressesByHash[adressHash]
|
||||||
except:
|
except:
|
||||||
|
@ -357,7 +352,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
Inventory()[inventoryHash] = (
|
Inventory()[inventoryHash] = (
|
||||||
objectType, streamNumber, payload, embeddedTime, '')
|
objectType, streamNumber, payload, embeddedTime, '')
|
||||||
|
|
||||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
logger.info('broadcasting inv with hash: %s', hexlify(inventoryHash))
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||||
|
@ -370,9 +365,12 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# before this finished.
|
# before this finished.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# If this isn't a chan address, this function assembles
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# the pubkey data, does the necessary POW and sends it out.
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
def sendOutOrStoreMyV4Pubkey(self, myAddress):
|
def sendOutOrStoreMyV4Pubkey(self, myAddress):
|
||||||
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
It doesn't send directly anymore. It put is to a queue for another thread to send at an appropriate time,
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
whereas in the past it directly appended it to the outgoing buffer, I think. Same with all the other methods in
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
this class.
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
if not BMConfigParser().has_section(myAddress):
|
if not BMConfigParser().has_section(myAddress):
|
||||||
# The address has been deleted.
|
# The address has been deleted.
|
||||||
return
|
return
|
||||||
|
@ -444,7 +442,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
doubleHashOfAddressData[32:]
|
doubleHashOfAddressData[32:]
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
logger.info('broadcasting inv with hash: %s', hexlify(inventoryHash))
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
queues.invQueue.put((streamNumber, inventoryHash))
|
queues.invQueue.put((streamNumber, inventoryHash))
|
||||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||||
|
@ -459,6 +457,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)
|
)
|
||||||
|
|
||||||
def sendBroadcast(self):
|
def sendBroadcast(self):
|
||||||
|
"""Send a broadcast-type object (assemble the object, perform PoW and put it to the inv announcement queue)"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# Reset just in case
|
# Reset just in case
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE sent SET status='broadcastqueued' '''
|
'''UPDATE sent SET status='broadcastqueued' '''
|
||||||
|
@ -627,6 +626,8 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)
|
)
|
||||||
|
|
||||||
def sendMsg(self):
|
def sendMsg(self):
|
||||||
|
"""Send a message-type object (assemble the object, perform PoW and put it to the inv announcement queue)"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
# pylint: disable=too-many-nested-blocks
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# Reset just in case
|
# Reset just in case
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE sent SET status='msgqueued' '''
|
'''UPDATE sent SET status='msgqueued' '''
|
||||||
|
@ -740,10 +741,8 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# object associated with the tag for this toAddress.
|
# object associated with the tag for this toAddress.
|
||||||
if toAddressVersionNumber >= 4:
|
if toAddressVersionNumber >= 4:
|
||||||
doubleHashOfToAddressData = hashlib.sha512(
|
doubleHashOfToAddressData = hashlib.sha512(
|
||||||
hashlib.sha512(encodeVarint(
|
hashlib.sha512(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
toAddressVersionNumber) +
|
encodeVarint(toAddressVersionNumber) + encodeVarint(toStreamNumber) + toRipe
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
encodeVarint(toStreamNumber) +
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
toRipe
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
).digest()
|
).digest()
|
||||||
).digest()
|
).digest()
|
||||||
# The first half of the sha512 hash.
|
# The first half of the sha512 hash.
|
||||||
|
@ -834,7 +833,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'SELECT transmitdata FROM pubkeys WHERE address=?',
|
'SELECT transmitdata FROM pubkeys WHERE address=?',
|
||||||
toaddress)
|
toaddress)
|
||||||
for row in queryreturn:
|
for row in queryreturn: # pylint: disable=redefined-outer-name
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
pubkeyPayload, = row
|
pubkeyPayload, = row
|
||||||
|
|
||||||
# The pubkey message is stored with the following items
|
# The pubkey message is stored with the following items
|
||||||
|
@ -939,40 +938,43 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
requiredAverageProofOfWorkNonceTrialsPerByte,
|
requiredAverageProofOfWorkNonceTrialsPerByte,
|
||||||
requiredPayloadLengthExtraBytes
|
requiredPayloadLengthExtraBytes
|
||||||
)
|
)
|
||||||
queues.UISignalQueue.put((
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'updateSentItemStatusByAckdata', (
|
queues.UISignalQueue.put(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
ackdata,
|
(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
tr._translate(
|
'updateSentItemStatusByAckdata',
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
"MainWindow",
|
(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
"Doing work necessary to send message.\n"
|
ackdata,
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
"Receiver\'s required difficulty: %1"
|
tr._translate(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
" and %2"
|
"MainWindow",
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
).arg(str(float(
|
"Doing work necessary to send message.\n"
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
requiredAverageProofOfWorkNonceTrialsPerByte) /
|
"Receiver\'s required difficulty: %1"
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
" and %2"
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)).arg(str(float(
|
).arg(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
requiredPayloadLengthExtraBytes) /
|
str(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
defaults.networkDefaultPayloadLengthExtraBytes
|
float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)))))
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
).arg(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
str(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
float(requiredPayloadLengthExtraBytes) /
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
)
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
if status != 'forcepow':
|
if status != 'forcepow':
|
||||||
if (requiredAverageProofOfWorkNonceTrialsPerByte
|
maxacceptablenoncetrialsperbyte = BMConfigParser().getint(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
> BMConfigParser().getint(
|
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'bitmessagesettings',
|
maxacceptablepayloadlengthextrabytes = BMConfigParser().getint(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'maxacceptablenoncetrialsperbyte'
|
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
) and
|
cond1 = maxacceptablenoncetrialsperbyte and \
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
BMConfigParser().getint(
|
requiredAverageProofOfWorkNonceTrialsPerByte > maxacceptablenoncetrialsperbyte
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'bitmessagesettings',
|
cond2 = maxacceptablepayloadlengthextrabytes and \
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'maxacceptablenoncetrialsperbyte'
|
requiredPayloadLengthExtraBytes > maxacceptablepayloadlengthextrabytes
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
) != 0) or (
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
requiredPayloadLengthExtraBytes
|
if cond1 or cond2:
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
> BMConfigParser().getint(
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'bitmessagesettings',
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'maxacceptablepayloadlengthextrabytes'
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
) and
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
BMConfigParser().getint(
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'bitmessagesettings',
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'maxacceptablepayloadlengthextrabytes'
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
) != 0):
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# The demanded difficulty is more than
|
# The demanded difficulty is more than
|
||||||
# we are willing to do.
|
# we are willing to do.
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
|
@ -988,19 +990,15 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
" the recipient (%1 and %2) is"
|
" the recipient (%1 and %2) is"
|
||||||
" more difficult than you are"
|
" more difficult than you are"
|
||||||
" willing to do. %3"
|
" willing to do. %3"
|
||||||
).arg(str(float(
|
).arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
requiredAverageProofOfWorkNonceTrialsPerByte)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
/ defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
str(float(requiredPayloadLengthExtraBytes) /
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)).arg(str(float(
|
defaults.networkDefaultPayloadLengthExtraBytes)).arg(
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
requiredPayloadLengthExtraBytes)
|
l10n.formatTimestamp()))))
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
/ defaults.networkDefaultPayloadLengthExtraBytes
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
)).arg(l10n.formatTimestamp()))
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
))
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
continue
|
continue
|
||||||
else: # if we are sending a message to ourselves or a chan..
|
else: # if we are sending a message to ourselves or a chan..
|
||||||
logger.info('Sending a message.')
|
logger.info('Sending a message.')
|
||||||
logger.debug(
|
logger.debug('First 150 characters of message: %r', message[:150])
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
'First 150 characters of message: %r', message[:150])
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
behaviorBitfield = protocol.getBitfield(fromaddress)
|
behaviorBitfield = protocol.getBitfield(fromaddress)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1199,16 +1197,14 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
Inventory()[inventoryHash] = (
|
Inventory()[inventoryHash] = (
|
||||||
objectType, toStreamNumber, encryptedPayload, embeddedTime, '')
|
objectType, toStreamNumber, encryptedPayload, embeddedTime, '')
|
||||||
if BMConfigParser().has_section(toaddress) or \
|
if BMConfigParser().has_section(toaddress) or \
|
||||||
not protocol.checkBitfield(
|
not protocol.checkBitfield(behaviorBitfield, protocol.BITFIELD_DOESACK):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
behaviorBitfield, protocol.BITFIELD_DOESACK):
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateSentItemStatusByAckdata', (
|
'updateSentItemStatusByAckdata', (
|
||||||
ackdata,
|
ackdata,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
"Message sent. Sent at %1"
|
"Message sent. Sent at %1"
|
||||||
).arg(l10n.formatTimestamp()))
|
).arg(l10n.formatTimestamp()))))
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
))
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
else:
|
else:
|
||||||
# not sending to a chan or one of my addresses
|
# not sending to a chan or one of my addresses
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
|
@ -1229,8 +1225,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# Update the sent message in the sent table with the
|
# Update the sent message in the sent table with the
|
||||||
# necessary information.
|
# necessary information.
|
||||||
if BMConfigParser().has_section(toaddress) or \
|
if BMConfigParser().has_section(toaddress) or \
|
||||||
not protocol.checkBitfield(
|
not protocol.checkBitfield(behaviorBitfield, protocol.BITFIELD_DOESACK):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
behaviorBitfield, protocol.BITFIELD_DOESACK):
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
newStatus = 'msgsentnoackexpected'
|
newStatus = 'msgsentnoackexpected'
|
||||||
else:
|
else:
|
||||||
newStatus = 'msgsent'
|
newStatus = 'msgsent'
|
||||||
|
@ -1270,6 +1265,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
call([apiNotifyPath, "newMessage"])
|
call([apiNotifyPath, "newMessage"])
|
||||||
|
|
||||||
def requestPubKey(self, toAddress):
|
def requestPubKey(self, toAddress):
|
||||||
|
"""Send a getpubkey object"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
toStatus, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
toStatus, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||||
toAddress)
|
toAddress)
|
||||||
if toStatus != 'success':
|
if toStatus != 'success':
|
||||||
|
@ -1286,7 +1282,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
''' LIMIT 1''',
|
''' LIMIT 1''',
|
||||||
toAddress
|
toAddress
|
||||||
)
|
)
|
||||||
if len(queryReturn) == 0:
|
if not queryReturn:
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
logger.critical(
|
logger.critical(
|
||||||
'BUG: Why are we requesting the pubkey for %s'
|
'BUG: Why are we requesting the pubkey for %s'
|
||||||
' if there are no messages in the sent folder'
|
' if there are no messages in the sent folder'
|
||||||
|
@ -1389,16 +1385,14 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
).arg(l10n.formatTimestamp()))
|
).arg(l10n.formatTimestamp()))
|
||||||
))
|
))
|
||||||
|
|
||||||
def generateFullAckMessage(self, ackdata, toStreamNumber, TTL):
|
def generateFullAckMessage(self, ackdata, _, TTL):
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# It might be perfectly fine to just use the same TTL for
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# the ackdata that we use for the message. But I would rather
|
It might be perfectly fine to just use the same TTL for the ackdata that we use for the message. But I would
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# it be more difficult for attackers to associate ackData with
|
rather it be more difficult for attackers to associate ackData with the associated msg object. However, users
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# the associated msg object. However, users would want the TTL
|
would want the TTL of the acknowledgement to be about the same as they set for the message itself. So let's set
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# of the acknowledgement to be about the same as they set
|
the TTL of the acknowledgement to be in one of three 'buckets': 1 hour, 7 days, or 28 days, whichever is
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# for the message itself. So let's set the TTL of the
|
relatively close to what the user specified.
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# acknowledgement to be in one of three 'buckets': 1 hour, 7
|
"""
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# days, or 28 days, whichever is relatively close to what the
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
# user specified.
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
|||||||
if TTL < 24 * 60 * 60: # 1 day
|
if TTL < 24 * 60 * 60: # 1 day
|
||||||
TTL = 24 * 60 * 60 # 1 day
|
TTL = 24 * 60 * 60 # 1 day
|
||||||
elif TTL < 7 * 24 * 60 * 60: # 1 week
|
elif TTL < 7 * 24 * 60 * 60: # 1 week
|
||||||
|
|
||||||
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
```suggestion
"""Format hashes per seconds nicely (SI prefix)"""
```
|
Reference in New Issue
Block a user