report bandwidth, only pull changes
This commit is contained in:
parent
1e17e4a9d1
commit
68383b8834
8 changed files with 78 additions and 26 deletions
26
oml/bandwidth.py
Normal file
26
oml/bandwidth.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import state
|
||||
from websocket import trigger_event
|
||||
|
||||
class Bandwidth(object):
|
||||
up = 0
|
||||
down = 0
|
||||
_last = {}
|
||||
|
||||
def __init__(self):
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
bandwidth = {'up': self.up, 'down': self.down}
|
||||
if bandwidth != self._last:
|
||||
trigger_event('bandwidth', bandwidth)
|
||||
self._last = bandwidth
|
||||
self.up = 0
|
||||
self.down = 0
|
||||
state.main.call_later(1, self.update)
|
||||
|
||||
def download(self, amount):
|
||||
self.down += amount * 8
|
||||
|
||||
def upload(self, amount):
|
||||
self.up += amount * 8
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue