From df059f872951ed8d9977f434dff6d24095f12a10 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 1 Nov 2007 18:24:06 -0400 Subject: [PATCH] Do some little improvements on the per-second update. --- example/delugent/delugent.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/example/delugent/delugent.py b/example/delugent/delugent.py index 540b4f5..7974e39 100755 --- a/example/delugent/delugent.py +++ b/example/delugent/delugent.py @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA """ +import profile import deluge.common import deluge.ui.client as client from deluge.log import LOG as log @@ -123,13 +124,22 @@ class TorRow(gobject.GObject): def __init__(self, id): self.__gobject_init__() self.id = id - self.row = None + self.row = [""] * self.COLS def __del__(self): pass def info(self): - status = client.get_torrent_status(self.id, status_keys.keys()) + keys = ['state', + 'name', + 'total_size', + 'progress', + 'num_peers', + 'num_seeds', + 'download_payload_rate', + 'upload_payload_rate', + 'eta'] + status = client.get_torrent_status(self.id, keys) state = int(status.get("state", 0)) name = str(status.get("name", "")) size = int(status.get("total_size", 0)) @@ -140,18 +150,16 @@ class TorRow(gobject.GObject): upspeed= float(status.get("upload_payload_rate", 0.0)) eta = float(status.get("eta", 0.0)) - row = [""] * self.COLS - row[self.COL_NAME] = name - row[self.COL_STATE] = show_state(state) - row[self.COL_SIZE] = show_size(size) - row[self.COL_PROG] = str(progress) - row[self.COL_SD] = str(seeds) - row[self.COL_PR] = str(peers) - row[self.COL_DS] = show_speed(dlspeed) - row[self.COL_US] = show_speed(upspeed) - row[self.COL_ETA] = str(eta) - self.row = row - return row + self.row[self.COL_NAME] = name + self.row[self.COL_STATE] = show_state(state) + self.row[self.COL_SIZE] = show_size(size) + self.row[self.COL_PROG] = str(progress) + self.row[self.COL_SD] = str(seeds) + self.row[self.COL_PR] = str(peers) + self.row[self.COL_DS] = show_speed(dlspeed) + self.row[self.COL_US] = show_speed(upspeed) + self.row[self.COL_ETA] = str(eta) + return self.row gobject.type_register(TorRow) @@ -245,8 +253,11 @@ class TorList(gnt.Tree): self.change_text(tor, i, info[i]) def update_all(self): + gnt.unset_flag(self, 1 << 2) for tor in self.get_rows(): self.update_torrent(tor.id, tor) + gnt.set_flag(self, 1 << 2) + self.draw() def show_info(self, null): tor = self.get_selection_data() @@ -721,4 +732,4 @@ def main(): gnt.gnt_quit() if __name__ == "__main__": - main() + profile.run('main()', 'profile') -- 2.11.4.GIT