stats pylint fixes

This commit is contained in:
lakshyacis 2019-09-10 20:00:42 +05:30
parent 7d0bd1cf7a
commit fcffb42629
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -1,3 +1,7 @@
"""
src/network/stats.py
====================
"""
import time import time
import asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
@ -14,6 +18,7 @@ currentSentSpeed = 0
def connectedHostsList(): def connectedHostsList():
"""List of all the connected hosts"""
retval = [] retval = []
for i in BMConnectionPool().inboundConnections.values() + \ for i in BMConnectionPool().inboundConnections.values() + \
BMConnectionPool().outboundConnections.values(): BMConnectionPool().outboundConnections.values():
@ -27,10 +32,13 @@ def connectedHostsList():
def sentBytes(): def sentBytes():
"""Sending Bytes"""
return asyncore.sentBytes return asyncore.sentBytes
def uploadSpeed(): def uploadSpeed():
"""Getting upload speed"""
# pylint: disable=global-statement
global lastSentTimestamp, lastSentBytes, currentSentSpeed global lastSentTimestamp, lastSentBytes, currentSentSpeed
currentTimestamp = time.time() currentTimestamp = time.time()
if int(lastSentTimestamp) < int(currentTimestamp): if int(lastSentTimestamp) < int(currentTimestamp):
@ -42,10 +50,13 @@ def uploadSpeed():
def receivedBytes(): def receivedBytes():
"""Receiving Bytes"""
return asyncore.receivedBytes return asyncore.receivedBytes
def downloadSpeed(): def downloadSpeed():
"""Getting download speed"""
# pylint: disable=global-statement
global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed
currentTimestamp = time.time() currentTimestamp = time.time()
if int(lastReceivedTimestamp) < int(currentTimestamp): if int(lastReceivedTimestamp) < int(currentTimestamp):
@ -58,6 +69,7 @@ def downloadSpeed():
def pendingDownload(): def pendingDownload():
"""Getting pending downloads"""
return len(missingObjects) return len(missingObjects)
# tmp = {} # tmp = {}
# for connection in BMConnectionPool().inboundConnections.values() + \ # for connection in BMConnectionPool().inboundConnections.values() + \
@ -68,6 +80,7 @@ def pendingDownload():
def pendingUpload(): def pendingUpload():
"""Getting pending uploads"""
# tmp = {} # tmp = {}
# for connection in BMConnectionPool().inboundConnections.values() + \ # for connection in BMConnectionPool().inboundConnections.values() + \
# BMConnectionPool().outboundConnections.values(): # BMConnectionPool().outboundConnections.values():