Browse Source

Updated rTorrent library and fixed some issues with ratio setup.

pull/1977/head
Dean Gardiner 12 years ago
parent
commit
2bb2e28f91
  1. 36
      couchpotato/core/downloaders/rtorrent/main.py
  2. 12
      libs/rtorrent/group.py

36
couchpotato/core/downloaders/rtorrent/main.py

@ -2,7 +2,7 @@ from base64 import b16encode, b32decode
from datetime import timedelta from datetime import timedelta
from hashlib import sha1 from hashlib import sha1
import shutil import shutil
import traceback from rtorrent.err import MethodError
from bencode import bencode, bdecode from bencode import bencode, bdecode
from couchpotato.core.downloaders.base import Downloader, StatusList from couchpotato.core.downloaders.base import Downloader, StatusList
@ -54,21 +54,26 @@ class rTorrent(Downloader):
if name not in views: if name not in views:
self.rt.create_group(name) self.rt.create_group(name)
log.debug('Updating provider ratio to %s, group name: %s', (data.get('seed_ratio'), name))
group = self.rt.get_group(name) group = self.rt.get_group(name)
if data.get('seed_ratio'): try:
# Explicitly set all group options to ensure it is setup correctly if data.get('seed_ratio'):
group.set_upload('1M') ratio = int(float(data.get('seed_ratio')) * 100)
group.set_min(int(data.get('seed_ratio') * 100)) log.debug('Updating provider ratio to %s, group name: %s', (ratio, name))
group.set_max(int(data.get('seed_ratio') * 100))
group.set_command('d.stop') # Explicitly set all group options to ensure it is setup correctly
group.enable() group.set_upload('1M')
else: group.set_min(ratio)
# Reset group action and disable it group.set_max(ratio)
group.set_command() group.set_command('d.stop')
group.disable() group.enable()
else:
# Reset group action and disable it
group.set_command()
group.disable()
except MethodError, err:
log.error('Unable to set group options: %s', err.message)
return False
return True return True
@ -80,7 +85,8 @@ class rTorrent(Downloader):
return False return False
group_name = 'cp_' + data.get('provider').lower() group_name = 'cp_' + data.get('provider').lower()
self._update_provider_group(group_name, data) if not self._update_provider_group(group_name, data):
return False
torrent_params = {} torrent_params = {}
if self.conf('label'): if self.conf('label'):

12
libs/rtorrent/group.py

@ -64,16 +64,12 @@ class Group:
multicall.call() multicall.call()
def enable(self): def enable(self):
m = rtorrent.rpc.Multicall(self) p = self._rt_obj._get_conn()
self.multicall_add(m, self._get_prefix() + 'enable') return getattr(p, self._get_prefix() + 'enable')()
return(m.call()[-1])
def disable(self): def disable(self):
m = rtorrent.rpc.Multicall(self) p = self._rt_obj._get_conn()
self.multicall_add(m, self._get_prefix() + 'disable') return getattr(p, self._get_prefix() + 'disable')()
return(m.call()[-1])
def set_command(self, *methods): def set_command(self, *methods):
methods = [m + '=' for m in methods] methods = [m + '=' for m in methods]

Loading…
Cancel
Save