Allow config delete
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
from base64 import b16encode, b32decode
|
from base64 import b16encode, b32decode
|
||||||
from bencode import bencode, bdecode
|
from bencode import bencode, bdecode
|
||||||
from couchpotato.core.downloaders.base import Downloader, ReleaseDownloadList
|
from couchpotato.core.downloaders.base import Downloader, ReleaseDownloadList
|
||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent, addEvent
|
||||||
from couchpotato.core.helpers.encoding import sp
|
from couchpotato.core.helpers.encoding import sp
|
||||||
from couchpotato.core.helpers.variable import cleanHost
|
from couchpotato.core.helpers.variable import cleanHost, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
@@ -22,11 +22,24 @@ class rTorrent(Downloader):
|
|||||||
# Migration url to host options
|
# Migration url to host options
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(rTorrent, self).__init__()
|
super(rTorrent, self).__init__()
|
||||||
if self.conf('url'):
|
|
||||||
self.conf('ssl', value = (self.conf('url').split('://')[0].strip() == 'https'))
|
addEvent('app.load', self.migrate)
|
||||||
self.conf('host', value = self.conf('url').split('://')[-1].split('/')[0].strip())
|
|
||||||
self.conf('rpc_url', value = self.conf('url').split('://')[-1].split('/',1)[1].strip('/ '))
|
def migrate(self):
|
||||||
self.conf('url', value = '')
|
|
||||||
|
url = self.conf('url')
|
||||||
|
if url:
|
||||||
|
print url
|
||||||
|
|
||||||
|
url = 'http://localhost:8080/RPC2teasd/asdasd//'
|
||||||
|
host_split = splitString(url.split('://')[-1], split_on = '/')
|
||||||
|
|
||||||
|
self.conf('ssl', value = url.startswith('https'))
|
||||||
|
self.conf('host', value = host_split[0].strip())
|
||||||
|
self.conf('rpc_url', value = '/'.join(host_split[1:]))
|
||||||
|
|
||||||
|
self.deleteConf('url')
|
||||||
|
#self.conf('url', value = '')
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
# Already connected?
|
# Already connected?
|
||||||
@@ -167,14 +180,14 @@ class rTorrent(Downloader):
|
|||||||
torrent_files = []
|
torrent_files = []
|
||||||
for file_item in torrent.get_files():
|
for file_item in torrent.get_files():
|
||||||
torrent_files.append(sp(os.path.join(torrent.directory, file_item.path)))
|
torrent_files.append(sp(os.path.join(torrent.directory, file_item.path)))
|
||||||
|
|
||||||
status = 'busy'
|
status = 'busy'
|
||||||
if torrent.complete:
|
if torrent.complete:
|
||||||
if torrent.active:
|
if torrent.active:
|
||||||
status = 'seeding'
|
status = 'seeding'
|
||||||
else:
|
else:
|
||||||
status = 'completed'
|
status = 'completed'
|
||||||
|
|
||||||
release_downloads.append({
|
release_downloads.append({
|
||||||
'id': torrent.info_hash,
|
'id': torrent.info_hash,
|
||||||
'name': torrent.name,
|
'name': torrent.name,
|
||||||
|
|||||||
@@ -52,8 +52,11 @@ class Plugin(object):
|
|||||||
self.registerStatic(inspect.getfile(self.__class__))
|
self.registerStatic(inspect.getfile(self.__class__))
|
||||||
|
|
||||||
def conf(self, attr, value = None, default = None, section = None):
|
def conf(self, attr, value = None, default = None, section = None):
|
||||||
class_name = self.getName().lower().split(':')
|
class_name = self.getName().lower().split(':')[0].lower()
|
||||||
return Env.setting(attr, section = section if section else class_name[0].lower(), value = value, default = default)
|
return Env.setting(attr, section = section if section else class_name, value = value, default = default)
|
||||||
|
|
||||||
|
def deleteConf(self, attr):
|
||||||
|
return Env._settings.delete(attr, section = self.getName().lower().split(':')[0].lower())
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self._class_name or self.__class__.__name__
|
return self._class_name or self.__class__.__name__
|
||||||
|
|||||||
@@ -110,6 +110,9 @@ class Settings(object):
|
|||||||
except:
|
except:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
def delete(self, option = '', section = 'core'):
|
||||||
|
self.p.remove_option(section, option)
|
||||||
|
|
||||||
def getEnabler(self, section, option):
|
def getEnabler(self, section, option):
|
||||||
return self.getBool(section, option)
|
return self.getBool(section, option)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user