Addition of bytes received/sent counts on the network information tab.

This commit is contained in:
Yuri 2014-07-07 13:30:23 -07:00
parent cc21d629c9
commit f107b0fbd9
6 changed files with 66 additions and 14 deletions

View File

@ -1459,14 +1459,23 @@ class MyForm(QtGui.QMainWindow):
def updateNumberOfMessagesProcessed(self): def updateNumberOfMessagesProcessed(self):
self.ui.labelMessageCount.setText(_translate( self.ui.labelMessageCount.setText(_translate(
"MainWindow", "Processed %1 person-to-person messages.").arg(str(shared.numberOfMessagesProcessed))) "MainWindow", "Processed %1 person-to-person messages.").arg(str(shared.numberOfMessagesProcessed)))
self.updateNumberOfBytes()
def updateNumberOfBroadcastsProcessed(self): def updateNumberOfBroadcastsProcessed(self):
self.ui.labelBroadcastCount.setText(_translate( self.ui.labelBroadcastCount.setText(_translate(
"MainWindow", "Processed %1 broadcast messages.").arg(str(shared.numberOfBroadcastsProcessed))) "MainWindow", "Processed %1 broadcast messages.").arg(str(shared.numberOfBroadcastsProcessed)))
self.updateNumberOfBytes()
def updateNumberOfPubkeysProcessed(self): def updateNumberOfPubkeysProcessed(self):
self.ui.labelPubkeyCount.setText(_translate( self.ui.labelPubkeyCount.setText(_translate(
"MainWindow", "Processed %1 public keys.").arg(str(shared.numberOfPubkeysProcessed))) "MainWindow", "Processed %1 public keys.").arg(str(shared.numberOfPubkeysProcessed)))
self.updateNumberOfBytes()
def updateNumberOfBytes(self):
self.ui.labelBytesRecvCount.setText(_translate(
"MainWindow", "Received %1 bytes.").arg(str(locale.format("%d", shared.numberOfBytesReceived, grouping=True))))
self.ui.labelBytesSentCount.setText(_translate(
"MainWindow", "Sent %1 bytes.").arg(str(locale.format("%d", shared.numberOfBytesSent, grouping=True))))
def updateNetworkStatusTab(self): def updateNetworkStatusTab(self):
# print 'updating network status tab' # print 'updating network status tab'
@ -1521,6 +1530,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.labelLookupsPerSecond.setText(_translate( self.ui.labelLookupsPerSecond.setText(_translate(
"MainWindow", "Inventory lookups per second: %1").arg(str(shared.numberOfInventoryLookupsPerformed/2))) "MainWindow", "Inventory lookups per second: %1").arg(str(shared.numberOfInventoryLookupsPerformed/2)))
shared.numberOfInventoryLookupsPerformed = 0 shared.numberOfInventoryLookupsPerformed = 0
self.updateNumberOfBytes()
# Indicates whether or not there is a connection to the Bitmessage network # Indicates whether or not there is a connection to the Bitmessage network
connected = False connected = False

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'bitmessageui.ui' # Form implementation generated from reading ui file 'bitmessageui.ui'
# #
# Created: Sat Nov 2 18:01:09 2013 # Created: Mon Jul 7 12:26:18 2014
# by: PyQt4 UI code generator 4.10 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -431,15 +431,21 @@ class Ui_MainWindow(object):
self.labelBroadcastCount.setGeometry(QtCore.QRect(350, 150, 351, 16)) self.labelBroadcastCount.setGeometry(QtCore.QRect(350, 150, 351, 16))
self.labelBroadcastCount.setObjectName(_fromUtf8("labelBroadcastCount")) self.labelBroadcastCount.setObjectName(_fromUtf8("labelBroadcastCount"))
self.labelLookupsPerSecond = QtGui.QLabel(self.networkstatus) self.labelLookupsPerSecond = QtGui.QLabel(self.networkstatus)
self.labelLookupsPerSecond.setGeometry(QtCore.QRect(320, 210, 291, 16)) self.labelLookupsPerSecond.setGeometry(QtCore.QRect(320, 230, 291, 16))
self.labelLookupsPerSecond.setObjectName(_fromUtf8("labelLookupsPerSecond")) self.labelLookupsPerSecond.setObjectName(_fromUtf8("labelLookupsPerSecond"))
self.labelBytesRecvCount = QtGui.QLabel(self.networkstatus)
self.labelBytesRecvCount.setGeometry(QtCore.QRect(350, 190, 331, 16))
self.labelBytesRecvCount.setObjectName(_fromUtf8("labelBytesRecvCount"))
self.labelBytesSentCount = QtGui.QLabel(self.networkstatus)
self.labelBytesSentCount.setGeometry(QtCore.QRect(350, 210, 331, 16))
self.labelBytesSentCount.setObjectName(_fromUtf8("labelBytesSentCount"))
icon9 = QtGui.QIcon() icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/networkstatus.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/networkstatus.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.tabWidget.addTab(self.networkstatus, icon9, _fromUtf8("")) self.tabWidget.addTab(self.networkstatus, icon9, _fromUtf8(""))
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow) self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27)) self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 20))
self.menubar.setObjectName(_fromUtf8("menubar")) self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuFile = QtGui.QMenu(self.menubar) self.menuFile = QtGui.QMenu(self.menubar)
self.menuFile.setObjectName(_fromUtf8("menuFile")) self.menuFile.setObjectName(_fromUtf8("menuFile"))
@ -501,7 +507,7 @@ class Ui_MainWindow(object):
self.menubar.addAction(self.menuHelp.menuAction()) self.menubar.addAction(self.menuHelp.menuAction())
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(7)
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditTo.setEnabled) QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditTo.setEnabled)
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.labelSendBroadcastWarning.hide) QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.labelSendBroadcastWarning.hide)
QtCore.QObject.connect(self.radioButtonBroadcast, QtCore.SIGNAL(_fromUtf8("clicked()")), self.labelSendBroadcastWarning.show) QtCore.QObject.connect(self.radioButtonBroadcast, QtCore.SIGNAL(_fromUtf8("clicked()")), self.labelSendBroadcastWarning.show)
@ -625,6 +631,8 @@ class Ui_MainWindow(object):
self.labelPubkeyCount.setText(_translate("MainWindow", "Processed 0 public key.", None)) self.labelPubkeyCount.setText(_translate("MainWindow", "Processed 0 public key.", None))
self.labelBroadcastCount.setText(_translate("MainWindow", "Processed 0 broadcast.", None)) self.labelBroadcastCount.setText(_translate("MainWindow", "Processed 0 broadcast.", None))
self.labelLookupsPerSecond.setText(_translate("MainWindow", "Inventory lookups per second: 0", None)) self.labelLookupsPerSecond.setText(_translate("MainWindow", "Inventory lookups per second: 0", None))
self.labelBytesRecvCount.setText(_translate("MainWindow", "Received 0 bytes.", None))
self.labelBytesSentCount.setText(_translate("MainWindow", "Sent 0 bytes.", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status", None))
self.menuFile.setTitle(_translate("MainWindow", "File", None)) self.menuFile.setTitle(_translate("MainWindow", "File", None))
self.menuSettings.setTitle(_translate("MainWindow", "Settings", None)) self.menuSettings.setTitle(_translate("MainWindow", "Settings", None))

View File

@ -57,7 +57,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>7</number>
</property> </property>
<widget class="QWidget" name="inbox"> <widget class="QWidget" name="inbox">
<attribute name="icon"> <attribute name="icon">
@ -1035,7 +1035,7 @@ p, li { white-space: pre-wrap; }
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>320</x> <x>320</x>
<y>210</y> <y>230</y>
<width>291</width> <width>291</width>
<height>16</height> <height>16</height>
</rect> </rect>
@ -1044,6 +1044,32 @@ p, li { white-space: pre-wrap; }
<string>Inventory lookups per second: 0</string> <string>Inventory lookups per second: 0</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labelBytesRecvCount">
<property name="geometry">
<rect>
<x>350</x>
<y>190</y>
<width>331</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Received 0 bytes.</string>
</property>
</widget>
<widget class="QLabel" name="labelBytesSentCount">
<property name="geometry">
<rect>
<x>350</x>
<y>210</y>
<width>331</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Sent 0 bytes.</string>
</property>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -1055,7 +1081,7 @@ p, li { white-space: pre-wrap; }
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>885</width> <width>885</width>
<height>27</height> <height>20</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View File

@ -68,7 +68,9 @@ class receiveDataThread(threading.Thread):
while True: while True:
dataLen = len(self.data) dataLen = len(self.data)
try: try:
self.data += self.sock.recv(4096) dataRecv = self.sock.recv(4096)
self.data += dataRecv
shared.numberOfBytesReceived += len(dataRecv)
except socket.timeout: except socket.timeout:
with shared.printLock: with shared.printLock:
print 'Timeout occurred waiting for data from', self.peer, '. Closing receiveData thread. (ID:', str(id(self)) + ')' print 'Timeout occurred waiting for data from', self.peer, '. Closing receiveData thread. (ID:', str(id(self)) + ')'

View File

@ -55,7 +55,7 @@ class sendDataThread(threading.Thread):
print 'Sending version packet: ', repr(datatosend) print 'Sending version packet: ', repr(datatosend)
try: try:
self.sock.sendall(datatosend) self.sendBytes(datatosend)
except Exception as err: except Exception as err:
# if not 'Bad file descriptor' in err: # if not 'Bad file descriptor' in err:
with shared.printLock: with shared.printLock:
@ -63,6 +63,10 @@ class sendDataThread(threading.Thread):
self.versionSent = 1 self.versionSent = 1
def sendBytes(self, data):
self.sock.sendall(data)
shared.numberOfBytesSent += len(data)
def run(self): def run(self):
while True: while True:
deststream, command, data = self.sendDataThreadQueue.get() deststream, command, data = self.sendDataThreadQueue.get()
@ -114,7 +118,7 @@ class sendDataThread(threading.Thread):
datatosend = datatosend + payload datatosend = datatosend + payload
try: try:
self.sock.sendall(datatosend) self.sendBytes(datatosend)
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'sendaddr: self.sock.sendall failed' print 'sendaddr: self.sock.sendall failed'
@ -136,7 +140,7 @@ class sendDataThread(threading.Thread):
headerData += pack('>L', len(payload)) headerData += pack('>L', len(payload))
headerData += hashlib.sha512(payload).digest()[:4] headerData += hashlib.sha512(payload).digest()[:4]
try: try:
self.sock.sendall(headerData + payload) self.sendBytes(headerData + payload)
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'sendinv: self.sock.sendall failed' print 'sendinv: self.sock.sendall failed'
@ -149,7 +153,7 @@ class sendDataThread(threading.Thread):
print 'Sending pong to', self.peer, 'to keep connection alive.' print 'Sending pong to', self.peer, 'to keep connection alive.'
try: try:
self.sock.sendall( self.sendBytes(
'\xE9\xBE\xB4\xD9\x70\x6F\x6E\x67\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcf\x83\xe1\x35') '\xE9\xBE\xB4\xD9\x70\x6F\x6E\x67\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcf\x83\xe1\x35')
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
@ -157,7 +161,7 @@ class sendDataThread(threading.Thread):
break break
elif command == 'sendRawData': elif command == 'sendRawData':
try: try:
self.sock.sendall(data) self.sendBytes(data)
self.lastTimeISentData = int(time.time()) self.lastTimeISentData = int(time.time())
except: except:
print 'Sending of data to', self.peer, 'failed. sendDataThread thread', self, 'ending now.' print 'Sending of data to', self.peer, 'failed. sendDataThread thread', self, 'ending now.'

View File

@ -70,6 +70,8 @@ numberOfMessagesProcessed = 0
numberOfBroadcastsProcessed = 0 numberOfBroadcastsProcessed = 0
numberOfPubkeysProcessed = 0 numberOfPubkeysProcessed = 0
numberOfInventoryLookupsPerformed = 0 numberOfInventoryLookupsPerformed = 0
numberOfBytesReceived = 0
numberOfBytesSent = 0
daemon = False daemon = False
inventorySets = {} # key = streamNumer, value = a set which holds the inventory object hashes that we are aware of. This is used whenever we receive an inv message from a peer to check to see what items are new to us. We don't delete things out of it; instead, the singleCleaner thread clears and refills it every couple hours. inventorySets = {} # key = streamNumer, value = a set which holds the inventory object hashes that we are aware of. This is used whenever we receive an inv message from a peer to check to see what items are new to us. We don't delete things out of it; instead, the singleCleaner thread clears and refills it every couple hours.
needToWriteKnownNodesToDisk = False # If True, the singleCleaner will write it to disk eventually. needToWriteKnownNodesToDisk = False # If True, the singleCleaner will write it to disk eventually.