mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-10 02:18:41 +00:00
add torrent can add paused. remove torrent works
This commit is contained in:
parent
68c04acf50
commit
ff3c3f7148
3 changed files with 36 additions and 7 deletions
|
@ -49,6 +49,7 @@ def add_torrent(t_file, options, success_cb, fail_cb):
|
||||||
t_options = {}
|
t_options = {}
|
||||||
if options["path"]:
|
if options["path"]:
|
||||||
t_options["download_location"] = os.path.expanduser(options["path"])
|
t_options["download_location"] = os.path.expanduser(options["path"])
|
||||||
|
t_options["add_paused"] = options["add_paused"]
|
||||||
|
|
||||||
# Keep a list of deferreds to make a DeferredList
|
# Keep a list of deferreds to make a DeferredList
|
||||||
if not os.path.exists(t_file):
|
if not os.path.exists(t_file):
|
||||||
|
|
|
@ -108,6 +108,9 @@ class ACTION:
|
||||||
RECHECK=4
|
RECHECK=4
|
||||||
REMOVE=5
|
REMOVE=5
|
||||||
|
|
||||||
|
REMOVE_DATA=6
|
||||||
|
REMOVE_NODATA=7
|
||||||
|
|
||||||
class FILTER:
|
class FILTER:
|
||||||
ALL=0
|
ALL=0
|
||||||
ACTIVE=1
|
ACTIVE=1
|
||||||
|
@ -258,7 +261,6 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
|
|
||||||
def _scroll_down(self, by):
|
def _scroll_down(self, by):
|
||||||
self.cursel = min(self.cursel + by,self.numtorrents)
|
self.cursel = min(self.cursel + by,self.numtorrents)
|
||||||
log.error("cursel: %d",self.cursel)
|
|
||||||
if ((self.curoff + self.rows - 5) < self.cursel):
|
if ((self.curoff + self.rows - 5) < self.cursel):
|
||||||
self.curoff = self.cursel - self.rows + 5
|
self.curoff = self.cursel - self.rows + 5
|
||||||
|
|
||||||
|
@ -349,6 +351,7 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def _torrent_action(self, idx, data):
|
def _torrent_action(self, idx, data):
|
||||||
|
log.error("Action %d",data)
|
||||||
ids = self._selected_torrent_ids()
|
ids = self._selected_torrent_ids()
|
||||||
if ids:
|
if ids:
|
||||||
if data==ACTION.PAUSE:
|
if data==ACTION.PAUSE:
|
||||||
|
@ -358,7 +361,23 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
log.debug("Resuming torrents: %s", ids)
|
log.debug("Resuming torrents: %s", ids)
|
||||||
client.core.resume_torrent(ids).addErrback(self._action_error)
|
client.core.resume_torrent(ids).addErrback(self._action_error)
|
||||||
elif data==ACTION.REMOVE:
|
elif data==ACTION.REMOVE:
|
||||||
log.error("Can't remove just yet")
|
def do_remove(tid,data):
|
||||||
|
ids = self._selected_torrent_ids()
|
||||||
|
if data:
|
||||||
|
wd = data==ACTION.REMOVE_DATA
|
||||||
|
for tid in ids:
|
||||||
|
log.debug("Removing torrent: %s,%d",tid,wd)
|
||||||
|
client.core.remove_torrent(tid,wd).addErrback(self._action_error)
|
||||||
|
if len(ids) == 1:
|
||||||
|
self.marked = []
|
||||||
|
self.last_mark = -1
|
||||||
|
return True
|
||||||
|
self.popup = SelectablePopup(self,"Confirm Remove",do_remove)
|
||||||
|
self.popup.add_line("Are you sure you want to remove the marked torrents?",selectable=False)
|
||||||
|
self.popup.add_line("Remove with _data",data=ACTION.REMOVE_DATA)
|
||||||
|
self.popup.add_line("Remove _torrent",data=ACTION.REMOVE_NODATA)
|
||||||
|
self.popup.add_line("_Cancel",data=0)
|
||||||
|
return False
|
||||||
elif data==ACTION.RECHECK:
|
elif data==ACTION.RECHECK:
|
||||||
log.debug("Rechecking torrents: %s", ids)
|
log.debug("Rechecking torrents: %s", ids)
|
||||||
client.core.force_recheck(ids).addErrback(self._action_error)
|
client.core.force_recheck(ids).addErrback(self._action_error)
|
||||||
|
@ -368,6 +387,7 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
if len(ids) == 1:
|
if len(ids) == 1:
|
||||||
self.marked = []
|
self.marked = []
|
||||||
self.last_mark = -1
|
self.last_mark = -1
|
||||||
|
return True
|
||||||
|
|
||||||
def _show_torrent_actions_popup(self):
|
def _show_torrent_actions_popup(self):
|
||||||
#cid = self._current_torrent_id()
|
#cid = self._current_torrent_id()
|
||||||
|
@ -407,6 +427,7 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
self.updater.status_dict = {"state":"Queued"}
|
self.updater.status_dict = {"state":"Queued"}
|
||||||
self._curr_filter = "Queued"
|
self._curr_filter = "Queued"
|
||||||
self._go_top = True
|
self._go_top = True
|
||||||
|
return True
|
||||||
|
|
||||||
def _show_torrent_filter_popup(self):
|
def _show_torrent_filter_popup(self):
|
||||||
self.popup = SelectablePopup(self,"Filter Torrents",self._torrent_filter)
|
self.popup = SelectablePopup(self,"Filter Torrents",self._torrent_filter)
|
||||||
|
@ -420,7 +441,8 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
self.popup.add_line("Q_ueued",data=FILTER.QUEUED,foreground="yellow")
|
self.popup.add_line("Q_ueued",data=FILTER.QUEUED,foreground="yellow")
|
||||||
|
|
||||||
def _do_add(self, result):
|
def _do_add(self, result):
|
||||||
log.debug("Doing adding %s (dl to %s)",result["file"],result["path"])
|
result["add_paused"] = (result["add_paused"] == "Yes")
|
||||||
|
log.debug("Adding Torrent: %s (dl path: %s) (paused: %d)",result["file"],result["path"],result["add_paused"])
|
||||||
def suc_cb(msg):
|
def suc_cb(msg):
|
||||||
self.report_message("Torrent Added",msg)
|
self.report_message("Torrent Added",msg)
|
||||||
def fail_cb(msg):
|
def fail_cb(msg):
|
||||||
|
@ -429,13 +451,21 @@ class AllTorrents(BaseMode, component.Component):
|
||||||
|
|
||||||
def _show_torrent_add_popup(self):
|
def _show_torrent_add_popup(self):
|
||||||
dl = ""
|
dl = ""
|
||||||
|
ap = 1
|
||||||
try:
|
try:
|
||||||
dl = self.coreconfig["download_location"]
|
dl = self.coreconfig["download_location"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
if self.coreconfig["add_paused"]:
|
||||||
|
ap = 0
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
self.popup = InputPopup(self,"Add Torrent (Esc to cancel)",close_cb=self._do_add)
|
self.popup = InputPopup(self,"Add Torrent (Esc to cancel)",close_cb=self._do_add)
|
||||||
self.popup.add_text_input("Enter path to torrent file:","file")
|
self.popup.add_text_input("Enter path to torrent file:","file")
|
||||||
self.popup.add_text_input("Enter save path:","path",dl)
|
self.popup.add_text_input("Enter save path:","path",dl)
|
||||||
|
self.popup.add_select_input("Add Paused:","add_paused",["Yes","No"],ap)
|
||||||
|
|
||||||
def report_message(self,title,message):
|
def report_message(self,title,message):
|
||||||
self.messages.append((title,message))
|
self.messages.append((title,message))
|
||||||
|
|
|
@ -229,8 +229,7 @@ class SelectablePopup(Popup):
|
||||||
return True
|
return True
|
||||||
elif c == curses.KEY_ENTER or c == 10:
|
elif c == curses.KEY_ENTER or c == 10:
|
||||||
idx = self._selectable_lines.index(self._selected)
|
idx = self._selectable_lines.index(self._selected)
|
||||||
self._selection_callback(idx,self._select_data[idx],*self._selection_args)
|
return self._selection_callback(idx,self._select_data[idx],*self._selection_args)
|
||||||
return True
|
|
||||||
if c > 31 and c < 256:
|
if c > 31 and c < 256:
|
||||||
if chr(c) == 'q':
|
if chr(c) == 'q':
|
||||||
return True # close the popup
|
return True # close the popup
|
||||||
|
@ -238,8 +237,7 @@ class SelectablePopup(Popup):
|
||||||
if uc in self._hotkeys:
|
if uc in self._hotkeys:
|
||||||
# exec hotkey action
|
# exec hotkey action
|
||||||
idx = self._selectable_lines.index(self._hotkeys[uc])
|
idx = self._selectable_lines.index(self._hotkeys[uc])
|
||||||
self._selection_callback(idx,self._select_data[idx],*self._selection_args)
|
return self._selection_callback(idx,self._select_data[idx],*self._selection_args)
|
||||||
return True
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue