gget r70 - trunk/gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r70 - trunk/gget
- Date: Mon, 11 Aug 2008 14:54:30 +0000 (UTC)
Author: johans
Date: Mon Aug 11 14:54:30 2008
New Revision: 70
URL: http://svn.gnome.org/viewvc/gget?rev=70&view=rev
Log:
Emit bitrate changes at most every second.
Modified:
trunk/gget/Download.py
Modified: trunk/gget/Download.py
==============================================================================
--- trunk/gget/Download.py (original)
+++ trunk/gget/Download.py Mon Aug 11 14:54:30 2008
@@ -89,6 +89,7 @@
self.percent_complete = 0
self.bit_rate = 0.0
+ self.last_bitrate = datetime.datetime.now()
self.old_status = -1
self.status = -1
@@ -186,8 +187,12 @@
def bitrate(self, bit_rate):
"""Callback with the download bitrate in kilobytes per second."""
if self.status not in [COMPLETED, PAUSED, CANCELED, ERROR]:
- self.bit_rate = bit_rate
- self.emit("bitrate", bit_rate)
+ # Only emit bitrate every second and when it changes
+ diff = datetime.datetime.now() - self.last_bitrate
+ if diff.seconds > 0 and self.bit_rate != bit_rate:
+ self.last_bitrate = datetime.datetime.now()
+ self.bit_rate = bit_rate
+ self.emit("bitrate", bit_rate)
def cancel(self):
"""Tries to cancel this download. Returns True if sucessful, else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]