From 8c49dd6e90219999b2cd3343f51b44f56fe0512e Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 14 Jun 2008 07:48:14 +0000 Subject: [PATCH] Fix move storage for remote hosts by adding a dialog for path entry. --- deluge/core/core.py | 4 +- deluge/core/torrentmanager.py | 2 +- deluge/ui/client.py | 4 +- deluge/ui/gtkui/glade/main_window.glade | 1347 +++++++++++++---------- deluge/ui/gtkui/menubar.py | 55 +- deluge/ui/signalreceiver.py | 14 +- 6 files changed, 821 insertions(+), 605 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index 104f9a9da..480a9a497 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -372,8 +372,8 @@ class Core( if not self.torrents[torrent_id].pause(): log.warning("Error pausing torrent %s", torrent_id) - def export_move_torrent(self, torrent_ids, dest): - log.debug("Moving torrents %s to %s", torrent_ids, dest) + def export_move_storage(self, torrent_ids, dest): + log.debug("Moving storage %s to %s", torrent_ids, dest) for torrent_id in torrent_ids: if not self.torrents[torrent_id].move_storage(dest): log.warning("Error moving torrent %s to %s", torrent_id, dest) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index ce0bc3105..1ff77ebec 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -309,7 +309,7 @@ class TorrentManager(component.Component): log.debug("handle id: %s", str(handle.info_hash())) # Create a Torrent object - torrent = Torrent(handle, options, state, filename=filename) + torrent = Torrent(handle, options, state, filename) # Add the torrent object to the dictionary self.torrents[torrent.torrent_id] = torrent if self.config["queue_new_to_top"]: diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 63e087250..630f4fd76 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -95,7 +95,7 @@ class CoreProxy(gobject.GObject): callback(ret) except: pass - except (socket.error, xmlrpclib.ProtocolError), e: + except (socket.error, xmlrpclib.ProtocolError, deluge.xmlrpclib.Fault), e: log.warning("Could not contact daemon: %s", e) self.set_core_uri(None) finally: @@ -160,7 +160,7 @@ class BaseClient(object): "set_torrent_max_connections", "set_torrent_max_upload_slots", "set_torrent_max_upload_speed", "set_torrent_max_download_speed", "set_torrent_private_flag", "set_torrent_file_priorities", - "block_ip_range", "remove_torrent", "pause_torrent", "move_torrent", + "block_ip_range", "remove_torrent", "pause_torrent", "move_storage", "resume_torrent", "force_reannounce", "force_recheck", "deregister_client", "register_client", "add_torrent_file", "set_torrent_prioritize_first_last"] diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index 10cff89c1..4f1ecab98 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -633,18 +633,6 @@ 8 15 5 - - - True - - - 5 - 6 - 3 - 4 - GTK_FILL - - @@ -658,274 +646,137 @@ - - True - 0 - <b>Auto Managed:</b> - True - - - 4 - 5 - 3 - 4 - GTK_FILL - - - - - True - - - 7 - 8 - 2 - 3 - GTK_FILL - - - - - True - - - 7 - 8 - 1 - 2 - GTK_FILL - - - - - True - 0 - <b>Seed Rank:</b> - True - - - 6 - 7 - 2 - 3 - GTK_FILL - - - - - True - 0 - <b>Seeding Time:</b> - True - - - 6 - 7 - 1 - 2 - GTK_FILL - - - - - True - - - 7 - 8 - GTK_FILL - - - - - True - 0 - <b>Active Time:</b> - True - - - 6 - 7 - GTK_FILL - - - - - True - 0 - True - True - - - 1 - 2 - 3 - 4 - GTK_FILL - - - - - True - 0 - - - 3 - 4 - 3 - 4 - GTK_FILL - - - - - True - 0 - PANGO_WRAP_CHAR - True - - - 1 - 6 - 4 - 5 - GTK_FILL - - - - - True - 0 - <b>Tracker Status:</b> - True - - - 4 - 5 - GTK_FILL - - - - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 5 - 6 - 2 - 3 - GTK_FILL - - - - - - True - 0 - 1 - <b>Availability:</b> - True - - - 4 - 5 - 2 - 3 - GTK_FILL - - - - - True - 0 - - - 3 - 4 - 2 - 3 - GTK_FILL - - - - + True 0 1 2 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + GTK_FILL + + + + + True + 0 + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 1 + 2 + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Downloaded:</b> + True + + + + + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Uploaded:</b> + True + + + + + 1 + 2 + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Share Ratio:</b> + True + + + + 2 3 GTK_FILL - + True - 0 + 5 + + + True + 0 + <b>Next Announce:</b> + True + + - 5 - 6 - 1 - 2 + 3 + 4 GTK_FILL - - True - 0 - <b>Peers:</b> - True - - - 4 - 5 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 5 - 6 - GTK_FILL - - - - - True - 0 - <b>Seeders:</b> - True - - - 4 - 5 - GTK_FILL - - - - + True 15 5 - + True 0 - <b>Pieces:</b> + <b>Speed:</b> True @@ -933,30 +784,6 @@ 2 3 - 3 - 4 - GTK_FILL - - - - - True - 15 - 5 - - - True - 0 - <b>ETA:</b> - True - - - - - 2 - 3 - 2 - 3 GTK_FILL @@ -983,15 +810,15 @@ - + True 15 5 - + True 0 - <b>Speed:</b> + <b>ETA:</b> True @@ -999,128 +826,301 @@ 2 3 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Next Announce:</b> - True - - - - - 3 - 4 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Share Ratio:</b> - True - - - - 2 3 GTK_FILL - + True + 15 5 - + True 0 - <b>Uploaded:</b> + <b>Pieces:</b> True - 1 - 2 + 2 + 3 + 3 + 4 GTK_FILL - + True - 5 - - - True - 0 - <b>Downloaded:</b> - True - - + 0 + <b>Seeders:</b> + True + 4 + 5 GTK_FILL - + True 0 - 3 - 4 + 5 + 6 + GTK_FILL + + + + + True + 0 + <b>Peers:</b> + True + + + 4 + 5 1 2 GTK_FILL - + + True + 0 + + + 5 + 6 + 1 + 2 + GTK_FILL + + + + True 0 1 2 - 1 - 2 + 2 + 3 GTK_FILL - + True 0 3 4 + 2 + 3 GTK_FILL - + + True + 0 + 1 + <b>Availability:</b> + True + + + 4 + 5 + 2 + 3 + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 5 + 6 + 2 + 3 + GTK_FILL + + + + + + True + 0 + <b>Tracker Status:</b> + True + + + 4 + 5 + GTK_FILL + + + + + + True + 0 + PANGO_WRAP_CHAR + True + + + 1 + 6 + 4 + 5 + GTK_FILL + + + + True 0 + + 3 + 4 + 3 + 4 + GTK_FILL + + + + + True + 0 + True + True + 1 2 + 3 + 4 + GTK_FILL + + + + + True + 0 + <b>Active Time:</b> + True + + + 6 + 7 + GTK_FILL + + + + + True + + + 7 + 8 + GTK_FILL + + + + + True + 0 + <b>Seeding Time:</b> + True + + + 6 + 7 + 1 + 2 + GTK_FILL + + + + + True + 0 + <b>Seed Rank:</b> + True + + + 6 + 7 + 2 + 3 + GTK_FILL + + + + + True + + + 7 + 8 + 1 + 2 + GTK_FILL + + + + + True + + + 7 + 8 + 2 + 3 + GTK_FILL + + + + + True + 0 + <b>Auto Managed:</b> + True + + + 4 + 5 + 3 + 4 + GTK_FILL + + + + + True + + + 5 + 6 + 3 + 4 GTK_FILL @@ -1207,7 +1207,7 @@ - + True 0 True @@ -1215,112 +1215,44 @@ 1 2 - 4 - 5 - - - - - - True - 0 - 1 - <b># of files:</b> - True - - - 4 - 5 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 4 - 1 - 2 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <b>Hash:</b> - True - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - True - - - 1 - 4 - 6 - 7 - - - - - - True - 0 - 1 - <b>Tracker:</b> - True - - - 6 - 7 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Total Size:</b> - True - - - - 3 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + + + 1 + 4 + 5 + 6 + + + + + + True + 0 + 1 + <b>Status:</b> + True + + + 5 + 6 GTK_FILL - + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 True PANGO_WRAP_CHAR @@ -1329,27 +1261,8 @@ 1 4 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 0 - 1 - <b>Name:</b> - True - - - - - GTK_FILL + 2 + 3 @@ -1376,7 +1289,108 @@ - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Name:</b> + True + + + + + GTK_FILL + + + + + + True + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Total Size:</b> + True + + + + + 3 + 4 + GTK_FILL + + + + + + True + 0 + 1 + <b>Tracker:</b> + True + + + 6 + 7 + GTK_FILL + + + + + + True + 0 + True + + + 1 + 4 + 6 + 7 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <b>Hash:</b> + True + + + 1 + 2 + GTK_FILL + + + + + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -1387,42 +1401,28 @@ 1 4 - 2 - 3 + 1 + 2 - + True 0 1 - <b>Status:</b> + <b># of files:</b> True - 5 - 6 + 4 + 5 GTK_FILL - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - - - 1 - 4 - 5 - 6 - - - - - + True 0 True @@ -1430,8 +1430,8 @@ 1 2 - 3 - 4 + 4 + 5 @@ -1614,7 +1614,7 @@ - + True True 6 @@ -1624,8 +1624,100 @@ 1 2 + 3 + 4 + + + + + + + True + 0 + Max Upload Slots: + + + 3 + 4 + GTK_FILL + + + + + + True + KiB/s + + + 2 + 3 + 1 + 2 + + + + + + + True + KiB/s + + + 2 + 3 + + + + + + + True + 0 + Max Download Speed: + + + GTK_FILL + + + + + + True + 0 + Max Upload Speed: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Max Connections: + + 2 3 + GTK_FILL + + + + + + True + True + 6 + 1 + -1 -1 999999 1 10 10 + 1 + + + 1 + 2 @@ -1649,110 +1741,18 @@ - + True True 6 1 -1 -1 999999 1 10 10 - 1 1 2 - - - - - - - True - 0 - Max Connections: - - 2 3 - GTK_FILL - - - - - - True - 0 - Max Upload Speed: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Max Download Speed: - - - GTK_FILL - - - - - - True - KiB/s - - - 2 - 3 - - - - - - - True - KiB/s - - - 2 - 3 - 1 - 2 - - - - - - - True - 0 - Max Upload Slots: - - - 3 - 4 - GTK_FILL - - - - - - True - True - 6 - 1 - -1 -1 999999 1 10 10 - - - 1 - 2 - 3 - 4 @@ -1963,4 +1963,193 @@ + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + Remove Torrent? + False + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-dialog-warning + 6 + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <big><b>Are you sure you want to remove the selected torrent?</b></big> + True + True + + + False + False + 1 + + + + + False + False + + + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 15 + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-dialog-warning + + + False + False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <i>The associated .torrent will be deleted!</i> + True + + + 1 + + + + + + + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 15 + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-dialog-warning + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <i>The downloaded data will be deleted!</i> + True + + + 1 + + + + + + + 3 + + + + + False + False + 5 + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_CENTER + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-cancel + True + 0 + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Remove Selected Torrent + 0 + + + 1 + + + + + False + GTK_PACK_END + + + + + diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index d9fe28048..3ec3d1079 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -274,23 +274,44 @@ class MenuBar(component.Component): def on_menuitem_move_activate(self, data=None): log.debug("on_menuitem_move_activate") - from deluge.configmanager import ConfigManager - config = ConfigManager("gtkui.conf") - chooser = gtk.FileChooserDialog(_("Choose a directory to move files to"\ - ) , component.get("MainWindow").window, \ - gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL, \ - gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) - if not common.windows_check(): - chooser.set_icon(common.get_logo(18)) - chooser.set_property("skip-taskbar-hint", True) - chooser.set_current_folder(config["choose_directory_dialog_path"]) - if chooser.run() == gtk.RESPONSE_OK: - result = chooser.get_filename() - config["choose_directory_dialog_path"] = result - client.move_torrent( - component.get("TorrentView").get_selected_torrents(), result) - chooser.destroy() - + if client.is_localhost(): + from deluge.configmanager import ConfigManager + config = ConfigManager("gtkui.conf") + chooser = gtk.FileChooserDialog(_("Choose a directory to move files to"\ + ) , component.get("MainWindow").window, \ + gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL, \ + gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) + if not common.windows_check(): + chooser.set_icon(common.get_logo(18)) + chooser.set_property("skip-taskbar-hint", True) + chooser.set_current_folder(config["choose_directory_dialog_path"]) + if chooser.run() == gtk.RESPONSE_OK: + result = chooser.get_filename() + config["choose_directory_dialog_path"] = result + client.move_storage( + component.get("TorrentView").get_selected_torrents(), result) + chooser.destroy() + else: + client.get_torrent_status(self.show_move_storage_dialog, component.get("TorrentView").get_selected_torrent(), ["save_path"]) + client.force_call(False) + + def show_move_storage_dialog(self, status): + log.debug("show_move_storage_dialog") + glade = gtk.glade.XML( + pkg_resources.resource_filename("deluge.ui.gtkui", + "glade/move_storage_dialog.glade")) + dialog = glade.get_widget("move_storage_dialog") + dialog.set_transient_for(self.window.window) + entry = glade.get_widget("entry_destination") + entry.set_text(status["save_path"]) + def _on_response_event(widget, response_id): + log.debug("Moving torrents to %s", entry.get_text()) + path = entry.get_text() + client.move_storage(component.get("TorrentView").get_selected_torrents(), path) + dialog.hide() + dialog.connect("response", _on_response_event) + dialog.show() + def on_menuitem_queue_top_activate(self, value): log.debug("on_menuitem_queue_top_activate") client.queue_top(None, component.get("TorrentView").get_selected_torrents()) diff --git a/deluge/ui/signalreceiver.py b/deluge/ui/signalreceiver.py index 5806e9402..910057e0e 100644 --- a/deluge/ui/signalreceiver.py +++ b/deluge/ui/signalreceiver.py @@ -114,12 +114,18 @@ class SignalReceiver( client.register_client(str(self.port)) t = threading.Thread(target=self.handle_thread) - t.start() + try: + t.start() + except Exception, e: + log.debug("Thread: %s", e) def handle_thread(self): - while not self._shutdown: - self.handle_request() - self._shutdown = False + try: + while not self._shutdown: + self.handle_request() + self._shutdown = False + except Exception, e: + log.debug("handle_thread: %s", e) def emit_signal(self, signal, *data): """Exported method used by the core to emit a signal to the client"""