From ddc6c0c15c132933e9676d563bad37288a3212f5 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 12 Dec 2010 17:45:40 +0100 Subject: universal progress (ex. unrar progress), link info now emits update event, updated .pot --- module/network/FtpRequest.py | 12 ++++++++++-- module/network/Request.py | 8 ++++++++ module/network/XdccRequest.py | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'module/network') diff --git a/module/network/FtpRequest.py b/module/network/FtpRequest.py index d8f556fea..a0986a9ed 100644 --- a/module/network/FtpRequest.py +++ b/module/network/FtpRequest.py @@ -54,6 +54,7 @@ class FtpRequest: self.averageSpeeds = [] self.averageSpeedTime = 0.0 self.averageSpeedCount = 0.0 + self.progressNotify = None self.speedLimitActive = False self.maxSpeed = 0 @@ -219,8 +220,15 @@ class FtpRequest: def progress(self, dl_t, dl_d, up_t, up_d): if self.abort: return False - self.dl_arrived = int(dl_d) - self.dl_size = int(dl_t) + self.dl_arrived = int(dl_d)+self.offset + self.dl_size = int(dl_t)+self.offset + + if self.progressNotify: + try: + progress = int(float(self.dl_arrived)/self.dl_size*100) + self.progressNotify(progress) + except: + pass def get_free_name(self, file_name): file_count = 0 diff --git a/module/network/Request.py b/module/network/Request.py index 3a3cd0f41..5314f97ab 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -63,6 +63,7 @@ class Request: self.isSlow = False self.cookieJar = None self.interface = interface + self.progressNotify = None # change this for connection information self.debug = False @@ -379,6 +380,13 @@ class Request: self.dl_arrived = int(dl_d)+self.offset self.dl_size = int(dl_t)+self.offset + if self.progressNotify: + try: + progress = int(float(self.dl_arrived)/self.dl_size*100) + self.progressNotify(progress) + except: + pass + def get_free_name(self, folder, file_name): file_count = 0 file_name = join(folder, file_name) diff --git a/module/network/XdccRequest.py b/module/network/XdccRequest.py index b65398dbc..18378cc6f 100644 --- a/module/network/XdccRequest.py +++ b/module/network/XdccRequest.py @@ -70,6 +70,7 @@ class XdccRequest: self.speedLimitActive = False self.maxSpeed = 0 self.isSlow = False + self.progressNotify = None # change this for connection information self.debug = False -- cgit v1.2.3