stats flake8 fixes

python3android
lakshyacis 3 years ago
parent 8182e159df
commit 7d0bd1cf7a
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
  1. 38
      src/network/stats.py

@ -4,6 +4,7 @@ import asyncore_pollchoose as asyncore
from network.connectionpool import BMConnectionPool
from objectracker import missingObjects
lastReceivedTimestamp = time.time()
lastReceivedBytes = 0
currentReceivedSpeed = 0
@ -11,6 +12,7 @@ lastSentTimestamp = time.time()
lastSentBytes = 0
currentSentSpeed = 0
def connectedHostsList():
retval = []
for i in BMConnectionPool().inboundConnections.values() + \
@ -23,9 +25,11 @@ def connectedHostsList():
pass
return retval
def sentBytes():
return asyncore.sentBytes
def uploadSpeed():
global lastSentTimestamp, lastSentBytes, currentSentSpeed
currentTimestamp = time.time()
@ -36,35 +40,39 @@ def uploadSpeed():
lastSentTimestamp = currentTimestamp
return currentSentSpeed
def receivedBytes():
return asyncore.receivedBytes
def downloadSpeed():
global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed
currentTimestamp = time.time()
if int(lastReceivedTimestamp) < int(currentTimestamp):
currentReceivedBytes = asyncore.receivedBytes
currentReceivedSpeed = int((currentReceivedBytes - lastReceivedBytes) /
(currentTimestamp - lastReceivedTimestamp))
currentReceivedSpeed = int(
(currentReceivedBytes - lastReceivedBytes) / (currentTimestamp - lastReceivedTimestamp))
lastReceivedBytes = currentReceivedBytes
lastReceivedTimestamp = currentTimestamp
return currentReceivedSpeed
def pendingDownload():
return len(missingObjects)
#tmp = {}
#for connection in BMConnectionPool().inboundConnections.values() + \
# BMConnectionPool().outboundConnections.values():
# for k in connection.objectsNewToMe.keys():
# tmp[k] = True
#return len(tmp)
# tmp = {}
# for connection in BMConnectionPool().inboundConnections.values() + \
# BMConnectionPool().outboundConnections.values():
# for k in connection.objectsNewToMe.keys():
# tmp[k] = True
# return len(tmp)
def pendingUpload():
#tmp = {}
#for connection in BMConnectionPool().inboundConnections.values() + \
# BMConnectionPool().outboundConnections.values():
# for k in connection.objectsNewToThem.keys():
# tmp[k] = True
#This probably isn't the correct logic so it's disabled
#return len(tmp)
# tmp = {}
# for connection in BMConnectionPool().inboundConnections.values() + \
# BMConnectionPool().outboundConnections.values():
# for k in connection.objectsNewToThem.keys():
# tmp[k] = True
# This probably isn't the correct logic so it's disabled
# return len(tmp)
return 0

Loading…
Cancel
Save