1
# Copyright (C) 2008-2011 LottaNZB Development Team
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; version 3.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16
from lottanzb.util.gobject_extras import gproperty
17
from lottanzb.config.sabnzbd import ListConfigSection, ListElementConfigSection
19
class Config(ListConfigSection):
20
def find_section_class(self, section):
23
class ServerConfig(ListElementConfigSection):
24
username = gproperty(type=str)
25
password = gproperty(type=str)
26
host = gproperty(type=str)
27
port = gproperty(type=int, default=119, minimum=0, maximum=2 ** 16 - 1)
28
enable = gproperty(type=bool, default=True)
29
fillserver = gproperty(type=bool, default=False)
30
connections = gproperty(type=int, default=6, minimum=0, maximum=100)
31
ssl = gproperty(type=bool, default=False)
32
timeout = gproperty(type=int, default=120, minimum=30, maximum=240)
33
optional = gproperty(type=bool, default=False)
35
def set_identifier(self, identifier):
36
# Don't use `str.split' as IPv6 host addresses contain ':'.
37
host, separator, port = identifier.rpartition(":") # @UnusedVariable
43
raise ValueError("Expected an identifier of type 'host:port', "
44
"got %r" % identifier)
46
def get_identifier(self):
47
return "%s:%s" % (self.host, self.port)
50
def needs_authentication(self):
51
return bool(self.username and self.password)