implement autoload directory preference

This commit is contained in:
Marcos Pinto 2007-11-05 01:05:34 +00:00
parent 580d2a2e84
commit 0dcc01c942
7 changed files with 93 additions and 19 deletions

View File

@ -2,6 +2,7 @@ Deluge 0.5.7 (xx November 2007)
* Blocklist plugin will now display errors, instead of just crashing on a bad * Blocklist plugin will now display errors, instead of just crashing on a bad
list list
* Add preference for the location of torrent files * Add preference for the location of torrent files
* Add autoload folder
Deluge 0.5.6.2 (31 October 2007) Deluge 0.5.6.2 (31 October 2007)
* Set default piece size to 256-KiB in TorrentCreator plugin and add 2048KiB * Set default piece size to 256-KiB in TorrentCreator plugin and add 2048KiB

1
TODO
View File

@ -1,4 +1,3 @@
for 0.5.7 for 0.5.7
* manual recheck * manual recheck
* add auto-pickup folder
* remap filenames * remap filenames

View File

@ -156,6 +156,73 @@
<property name="padding">2</property> <property name="padding">2</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkFrame" id="frame20">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment34">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table11">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">1</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkCheckButton" id="chk_autoload">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Autoload all torrent files in:</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment36">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkFileChooserButton" id="autoload_path_button">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="title" translatable="yes">Select A Folder</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Autoload&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">2</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<widget class="GtkFrame" id="frame6"> <widget class="GtkFrame" id="frame6">
<property name="visible">True</property> <property name="visible">True</property>
@ -253,7 +320,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="padding">2</property> <property name="padding">2</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -335,7 +402,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="padding">2</property> <property name="padding">2</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</widget> </widget>

View File

@ -396,19 +396,6 @@ class Manager:
pass pass
deluge_core.save_fastresume(uid, self.unique_IDs[uid].filename) deluge_core.save_fastresume(uid, self.unique_IDs[uid].filename)
# Load all NEW torrents in a . The GUI can call this every minute or so,
# if one wants a directory to be 'watched' (personally, I think it should only be
# done on user command).os.path.join(
def autoload_directory(self, directory, save_dir, compact):
for filename in os.listdir(directory):
if filename[-len(".torrent"):].lower() == ".torrent":
try:
self.add_torrent_ns(self, filename, save_dir, compact)
except DuplicateTorrentError:
pass
self.sync()
# State retrieval functions # State retrieval functions
def get_state(self): def get_state(self):
@ -845,11 +832,10 @@ class Manager:
unique_ID = deluge_core.add_torrent(torrent.filename, unique_ID = deluge_core.add_torrent(torrent.filename,
torrent.save_dir, torrent.save_dir,
torrent.compact) torrent.compact)
except DelugeError, e: except:
print "Error:", e print "Error probably bad torrent"
del self.state.torrents[torrent] del self.state.torrents[torrent]
raise e raise e
# print "Got unique ID:", unique_ID
ret = unique_ID ret = unique_ID
self.unique_IDs[unique_ID] = torrent self.unique_IDs[unique_ID] = torrent

View File

@ -93,6 +93,7 @@ class PreferencesDlg:
self.glade.get_widget("combo_dht_proxy_type").set_active(self.preferences.get("dht_proxy_type")) self.glade.get_widget("combo_dht_proxy_type").set_active(self.preferences.get("dht_proxy_type"))
self.glade.get_widget("combo_tracker_proxy_type").set_active(self.preferences.get("tracker_proxy_type")) self.glade.get_widget("combo_tracker_proxy_type").set_active(self.preferences.get("tracker_proxy_type"))
self.glade.get_widget("combo_web_proxy_type").set_active(self.preferences.get("web_proxy_type")) self.glade.get_widget("combo_web_proxy_type").set_active(self.preferences.get("web_proxy_type"))
self.glade.get_widget("chk_autoload").set_active(self.preferences.get("autoload"))
self.glade.get_widget("chk_send_info").set_active(self.preferences.get("send_info")) self.glade.get_widget("chk_send_info").set_active(self.preferences.get("send_info"))
self.glade.get_widget("chk_pref_rc4").set_active(self.preferences.get("pref_rc4")) self.glade.get_widget("chk_pref_rc4").set_active(self.preferences.get("pref_rc4"))
self.glade.get_widget("chk_peer_proxy").set_active(self.preferences.get("peer_proxy")) self.glade.get_widget("chk_peer_proxy").set_active(self.preferences.get("peer_proxy"))
@ -120,6 +121,7 @@ class PreferencesDlg:
self.glade.get_widget("txt_web_proxy_hostname").set_text(self.preferences.get("web_proxy_hostname")) self.glade.get_widget("txt_web_proxy_hostname").set_text(self.preferences.get("web_proxy_hostname"))
self.glade.get_widget("txt_web_proxy_username").set_text(self.preferences.get("web_proxy_username")) self.glade.get_widget("txt_web_proxy_username").set_text(self.preferences.get("web_proxy_username"))
self.glade.get_widget("txt_web_proxy_password").set_text(self.preferences.get("web_proxy_password")) self.glade.get_widget("txt_web_proxy_password").set_text(self.preferences.get("web_proxy_password"))
self.glade.get_widget("autoload_path_button").set_filename(self.preferences.get("default_autoload_path"))
self.glade.get_widget("download_path_button").set_filename(self.preferences.get("default_download_path")) self.glade.get_widget("download_path_button").set_filename(self.preferences.get("default_download_path"))
self.glade.get_widget("torrent_path_button").set_filename(self.preferences.get("default_torrent_path")) self.glade.get_widget("torrent_path_button").set_filename(self.preferences.get("default_torrent_path"))
self.glade.get_widget("chk_enable_files_dialog").set_active(self.preferences.get("enable_files_dialog")) self.glade.get_widget("chk_enable_files_dialog").set_active(self.preferences.get("enable_files_dialog"))
@ -202,6 +204,7 @@ class PreferencesDlg:
self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active()) self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active())
self.preferences.set("enclevel_type", self.glade.get_widget("combo_enclevel").get_active()) self.preferences.set("enclevel_type", self.glade.get_widget("combo_enclevel").get_active())
self.preferences.set("peer_proxy_type", self.glade.get_widget("combo_peer_proxy_type").get_active()) self.preferences.set("peer_proxy_type", self.glade.get_widget("combo_peer_proxy_type").get_active())
self.preferences.set("autoload", self.glade.get_widget("chk_autoload").get_active())
self.preferences.set("send_info", self.glade.get_widget("chk_send_info").get_active()) self.preferences.set("send_info", self.glade.get_widget("chk_send_info").get_active())
self.preferences.set("pref_rc4", self.glade.get_widget("chk_pref_rc4").get_active()) self.preferences.set("pref_rc4", self.glade.get_widget("chk_pref_rc4").get_active())
self.preferences.set("peer_proxy", self.glade.get_widget("chk_peer_proxy").get_active()) self.preferences.set("peer_proxy", self.glade.get_widget("chk_peer_proxy").get_active())
@ -238,6 +241,7 @@ class PreferencesDlg:
self.preferences.set("peer_proxy_password", self.glade.get_widget("txt_peer_proxy_password").get_text()) self.preferences.set("peer_proxy_password", self.glade.get_widget("txt_peer_proxy_password").get_text())
self.preferences.set("peer_proxy_hostname", self.glade.get_widget("txt_peer_proxy_hostname").get_text()) self.preferences.set("peer_proxy_hostname", self.glade.get_widget("txt_peer_proxy_hostname").get_text())
self.preferences.set("use_default_dir", self.glade.get_widget("radio_save_all_to").get_active()) self.preferences.set("use_default_dir", self.glade.get_widget("radio_save_all_to").get_active())
self.preferences.set("default_autoload_path", self.glade.get_widget("autoload_path_button").get_filename())
self.preferences.set("default_download_path", self.glade.get_widget("download_path_button").get_filename()) self.preferences.set("default_download_path", self.glade.get_widget("download_path_button").get_filename())
self.preferences.set("default_torrent_path", self.glade.get_widget("torrent_path_button").get_filename()) self.preferences.set("default_torrent_path", self.glade.get_widget("torrent_path_button").get_filename())
self.preferences.set("enable_files_dialog", self.glade.get_widget("chk_enable_files_dialog").get_active()) self.preferences.set("enable_files_dialog", self.glade.get_widget("chk_enable_files_dialog").get_active())
@ -322,6 +326,8 @@ class PreferencesDlg:
value = widget.get_active() value = widget.get_active()
if widget == self.glade.get_widget('radio_save_all_to'): if widget == self.glade.get_widget('radio_save_all_to'):
self.glade.get_widget('download_path_button').set_sensitive(value) self.glade.get_widget('download_path_button').set_sensitive(value)
self.glade.get_widget('autoload_path_button').set_sensitive(value)
self.glade.get_widget('chk_autoload').set_sensitive(value)
elif widget == self.glade.get_widget('chk_autoseed'): elif widget == self.glade.get_widget('chk_autoseed'):
self.glade.get_widget('ratio_spinner').set_sensitive(value) self.glade.get_widget('ratio_spinner').set_sensitive(value)
self.glade.get_widget('chk_clear_max_ratio_torrents').set_sensitive(value) self.glade.get_widget('chk_clear_max_ratio_torrents').set_sensitive(value)

View File

@ -986,6 +986,17 @@ window, please enter your password"))
## Call via a timer to update the interface ## Call via a timer to update the interface
def update(self): def update(self):
if self.config.get("autoload") and self.config.get("default_autoload_path"):
for filename in os.listdir(self.config.get("default_autoload_path")):
if filename[-len(".torrent"):].lower() == ".torrent":
try:
self.interactive_add_torrent_path(os.path.join(\
self.config.get("default_autoload_path"), filename), \
self.config.get("default_download_path"))
os.remove(os.path.join(self.config.get("default_autoload_path"), filename))
except:
pass
# We need to apply the queue changes # We need to apply the queue changes
self.manager.apply_queue() self.manager.apply_queue()

View File

@ -44,6 +44,7 @@ if common.windows_check():
"enabled_plugins" : "Torrent Files:Torrent Peers", "enabled_plugins" : "Torrent Files:Torrent Peers",
"file_manager" : common.FileManager.xdg, "file_manager" : common.FileManager.xdg,
"open_folder_stock" : True, "open_folder_stock" : True,
"autoload" : False,
"open_folder_location": "", "open_folder_location": "",
"send_info" : True, "send_info" : True,
"auto_end_seeding" : False, "auto_end_seeding" : False,
@ -52,6 +53,7 @@ if common.windows_check():
"enable_files_dialog" : False, "enable_files_dialog" : False,
"queue_above_completed" : False, "queue_above_completed" : False,
"clear_max_ratio_torrents" : False, "clear_max_ratio_torrents" : False,
"default_autoload_path" : os.path.expanduser("~"),
"default_torrent_path" : os.path.join(os.path.expanduser("~"), 'deluge', 'torrentfiles'), "default_torrent_path" : os.path.join(os.path.expanduser("~"), 'deluge', 'torrentfiles'),
"default_download_path" : os.path.expanduser("~"), "default_download_path" : os.path.expanduser("~"),
"open_torrent_dialog_path" : os.path.expanduser("~"), "open_torrent_dialog_path" : os.path.expanduser("~"),
@ -150,6 +152,7 @@ else:
"enabled_plugins" : "Torrent Files:Torrent Peers", "enabled_plugins" : "Torrent Files:Torrent Peers",
"file_manager" : common.FileManager.xdg, "file_manager" : common.FileManager.xdg,
"open_folder_stock" : True, "open_folder_stock" : True,
"autoload" : False,
"open_folder_location": "", "open_folder_location": "",
"send_info" : True, "send_info" : True,
"auto_end_seeding" : False, "auto_end_seeding" : False,
@ -158,6 +161,7 @@ else:
"enable_files_dialog" : False, "enable_files_dialog" : False,
"queue_above_completed" : False, "queue_above_completed" : False,
"clear_max_ratio_torrents" : False, "clear_max_ratio_torrents" : False,
"default_autoload_path" : os.path.expanduser("~"),
"default_torrent_path" : os.path.join(xdg.BaseDirectory.save_config_path('deluge'), 'torrentfiles'), "default_torrent_path" : os.path.join(xdg.BaseDirectory.save_config_path('deluge'), 'torrentfiles'),
"default_download_path" : os.path.expanduser("~"), "default_download_path" : os.path.expanduser("~"),
"open_torrent_dialog_path" : os.path.expanduser("~"), "open_torrent_dialog_path" : os.path.expanduser("~"),