Package DebTorrent :: Module RateMeasure :: Class RateMeasure
[hide private]
[frames] | no frames]

Class RateMeasure

source code

Simple measurement of the download rate.

Instance Methods [hide private]
 
__init__(self)
Initialize the instance.
source code
 
data_came_in(self, amount)
Add new data received to the rate.
source code
 
data_rejected(self, amount)
Add new data received to the rate.
source code
float
get_time_left(self, left)
Calculate the amount of time left to complete the download.
source code
 
update(self, amount)
Update the rate with new received data.
source code
Instance Variables [hide private]
boolean broke
unused
float got
the amount of data that's come in so far
boolean got_anything
whether any data has been received yet
float last
the last time the rate was updated
float last_checked
the last time the finishing time was calculated
boolean lastten
whether the download is in the last ten seconds
int rate
the last calculated download rate
float remaining
the number of seconds remaining from the last calculation
float time
the amount of time that has elapsed since data first came in
Method Details [hide private]

data_came_in(self, amount)

source code 
Add new data received to the rate.
Parameters:
  • amount (int) - the amount of data received

data_rejected(self, amount)

source code 
Add new data received to the rate.
Parameters:
  • amount (int) - the amount of data received

get_time_left(self, left)

source code 
Calculate the amount of time left to complete the download.
Parameters:
  • left (long) - the amount of data still to be downloaded
Returns: float
the number of seconds left in the download (or None if no data has been received)

update(self, amount)

source code 
Update the rate with new received data.
Parameters:
  • amount (int) - the amount of data received