From 0bc5ee6b556b4ccbb5d72dc3a4551ed5e8203991 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Wed, 24 Oct 2007 04:34:48 -0400 Subject: [PATCH] Sync with deluge changes upto r2047. --- example/delugent/delugent.py | 27 +++++++++++++++++---------- example/delugent/signals.py | 5 ++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/example/delugent/delugent.py b/example/delugent/delugent.py index 0120153..27da214 100755 --- a/example/delugent/delugent.py +++ b/example/delugent/delugent.py @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA """ -import deluge.ui.functions as functions +import deluge.ui.client as client from deluge.log import LOG as log import gnt @@ -101,7 +101,7 @@ class TorRow(gobject.GObject): pass def info(self): - status = functions.get_torrent_status(self.id, status_keys.keys()) + status = client.get_torrent_status(self.id, status_keys.keys()) state = int(status.get("state", 0)) name = str(status.get("name", "")) size = int(status.get("total_size", 0)) @@ -194,7 +194,7 @@ gobject.type_register(TorList) gnt.register_bindings(TorList) def show_details(tid): - status = functions.get_torrent_status(tid, status_keys.keys()) + status = client.get_torrent_status(tid, status_keys.keys()) status['state'] = show_state(status.get('state', '')) status['total_size'] = show_size(status.get('total_size', 0)) status['download_payload_rate'] = show_speed(status.get('download_payload_rate', 0.0)) @@ -230,9 +230,11 @@ def show_details(tid): ] for iter in range(0, len(keys)): key = keys[iter] - tv.append_text_with_flags(status_keys[key] + ": ", gnt.TEXT_FLAG_BOLD) - tv.append_text_with_flags(str(status.get(key, '')) + "\n", gnt.TEXT_FLAG_NORMAL) - string = string + status_keys[key] + ": " + str(status.get(key, '')) + "\n" + tag = ("%15s" % status_keys[key]) + ": " + value = str(status.get(key, '')) + tv.append_text_with_flags(tag, gnt.TEXT_FLAG_BOLD) + tv.append_text_with_flags(value + "\n", gnt.TEXT_FLAG_NORMAL) + string = string + tag + value + "\n" tv.attach_scroll_widget(win) tv.set_flag(gnt.TEXT_VIEW_TOP_ALIGN | gnt.TEXT_VIEW_NO_SCROLL) w, h = gnt.get_text_bound(string) @@ -247,7 +249,12 @@ def show_details(tid): win.add_widget(box) win.show() +def setup_deluge_core(): + client.set_core_uri("http://localhost:58846") + def main(): + setup_deluge_core() + win = gnt.Box(homo = False, vert = True) win.set_toplevel(True) win.set_title("Delugent") @@ -267,7 +274,7 @@ def main(): def file_selected(widget, path, file): files = widget.get_selected_multi_files() log.debug("adding files", files) - functions.add_torrent_file(files) + client.add_torrent_file(files) widget.destroy() fl = gnt.FileSel() fl.set_title("Select a Torrent") @@ -282,7 +289,7 @@ def main(): rm = gnt.Button("Remove") def rm_clicked(b): tor = list.get_selection_data() - functions.remove_torrent([tor.id]) + client.remove_torrent([tor.id]) rm.connect('activate', rm_clicked) hbox.add_widget(rm) gnt.gnt_util_set_trigger_widget(win, gnt.KEY_DEL, rm) @@ -292,7 +299,7 @@ def main(): pause = gnt.Button("Pause") def pause_clicked(b): tor = list.get_selection_data() - functions.pause_torrent([tor.id]) + client.pause_torrent([tor.id]) pause.connect('activate', pause_clicked) hbox.add_widget(pause) gnt.gnt_util_set_trigger_widget(win, 'p', pause) @@ -312,7 +319,7 @@ def main(): win.show() # Add the torrents in the list - session_state = functions.get_session_state() + session_state = client.get_session_state() for torrent_id in session_state: list.add_torrent(torrent_id) diff --git a/example/delugent/signals.py b/example/delugent/signals.py index 1199b74..df51e27 100644 --- a/example/delugent/signals.py +++ b/example/delugent/signals.py @@ -38,7 +38,7 @@ from deluge.log import LOG as log class Signals: def __init__(self, list): self.torrentlist = list - self.receiver = SignalReceiver(6200, "http://localhost:6666") + self.receiver = SignalReceiver(6200) self.receiver.start() self.receiver.connect_to_signal("torrent_added", self.torrent_added_signal) @@ -52,8 +52,7 @@ class Signals: self.torrent_all_resumed) def __del__(self): - return - self.receiver.stop() + self.receiver.shutdown() del self.receiver def torrent_added_signal(self, torrent_id): -- 2.11.4.GIT