Compare commits
1 Commits
f598a84dc0
...
7b78f54510
Author | SHA1 | Date | |
---|---|---|---|
7b78f54510 |
19
main.py
19
main.py
@@ -101,9 +101,9 @@ def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
|||||||
if 'Connection Speed' == stat:
|
if 'Connection Speed' == stat:
|
||||||
speed, unit = playerStats[stat].split()
|
speed, unit = playerStats[stat].split()
|
||||||
|
|
||||||
speedBytes = int(speed) * (1024 ** {'B/s': 0, 'KB/s': 1, 'MB/s': 2, 'GB/s': 3}[unit])
|
speedBytes = float(speed) * (1024 ** {'B/s': 0, 'KB/s': 1, 'MB/s': 2, 'GB/s': 3}[unit])
|
||||||
|
|
||||||
playerStats[stat] = {'Speed': int(speedBytes), 'Granularity': 's'}
|
playerStats[stat] = {'Speed': speedBytes, 'Granularity': 's'}
|
||||||
|
|
||||||
if 'Network Activity' == stat:
|
if 'Network Activity' == stat:
|
||||||
downString, upString = playerStats[stat].split(' / ')
|
downString, upString = playerStats[stat].split(' / ')
|
||||||
@@ -111,8 +111,8 @@ def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
|||||||
down, downUnit = downString.replace('down', '').strip().split()
|
down, downUnit = downString.replace('down', '').strip().split()
|
||||||
up, upUnit = upString.replace('up', '').strip().split()
|
up, upUnit = upString.replace('up', '').strip().split()
|
||||||
|
|
||||||
downBytes = int(down) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[downUnit])
|
downBytes = convert_to_bytes(down, downUnit)
|
||||||
upBytes = int(up) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[upUnit])
|
upBytes = convert_to_bytes(up, upUnit)
|
||||||
|
|
||||||
playerStats[stat] = {'Down': downBytes, 'Up': upBytes}
|
playerStats[stat] = {'Down': downBytes, 'Up': upBytes}
|
||||||
|
|
||||||
@@ -122,8 +122,8 @@ def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
|||||||
down, downUnit = downString.replace('down', '').strip().split()
|
down, downUnit = downString.replace('down', '').strip().split()
|
||||||
up, upUnit = upString.replace('up', '').strip().split()
|
up, upUnit = upString.replace('up', '').strip().split()
|
||||||
|
|
||||||
downBytes = int(down) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[downUnit])
|
downBytes = convert_to_bytes(down, downUnit)
|
||||||
upBytes = int(up) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[upUnit])
|
upBytes = convert_to_bytes(up, upUnit)
|
||||||
|
|
||||||
playerStats[stat] = {'Down': downBytes, 'Up': upBytes}
|
playerStats[stat] = {'Down': downBytes, 'Up': upBytes}
|
||||||
|
|
||||||
@@ -133,8 +133,8 @@ def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
|||||||
server, serverUnit = server.replace('from servers', '').strip().split()
|
server, serverUnit = server.replace('from servers', '').strip().split()
|
||||||
peer, peerUnit = peer.replace('from peers', '').strip().split()
|
peer, peerUnit = peer.replace('from peers', '').strip().split()
|
||||||
|
|
||||||
serverBytes = int(server) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[serverUnit])
|
serverBytes = convert_to_bytes(server, serverUnit)
|
||||||
peerBytes = int(peer) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[peerUnit])
|
peerBytes = convert_to_bytes(peer, peerUnit)
|
||||||
|
|
||||||
playerStats[stat] = {'Server': serverBytes, 'Peers': peerBytes}
|
playerStats[stat] = {'Server': serverBytes, 'Peers': peerBytes}
|
||||||
|
|
||||||
@@ -156,6 +156,9 @@ def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveStats([stats])
|
saveStats([stats])
|
||||||
|
|
||||||
|
def convert_to_bytes(down, downUnit):
|
||||||
|
return float(down) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[downUnit])
|
||||||
|
|
||||||
def setupStats(driver: webdriver.Remote, url: str):
|
def setupStats(driver: webdriver.Remote, url: str):
|
||||||
logger.log(logging.INFO, 'Setting up stats.')
|
logger.log(logging.INFO, 'Setting up stats.')
|
||||||
|
Reference in New Issue
Block a user