stats flake8 fixes
This commit is contained in:
parent
8182e159df
commit
7d0bd1cf7a
|
@ -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,20 +40,23 @@ 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 = {}
|
||||
|
@ -59,6 +66,7 @@ def pendingDownload():
|
|||
# tmp[k] = True
|
||||
# return len(tmp)
|
||||
|
||||
|
||||
def pendingUpload():
|
||||
# tmp = {}
|
||||
# for connection in BMConnectionPool().inboundConnections.values() + \
|
||||
|
|
Loading…
Reference in New Issue
Block a user