Add some sensible defaults, stop TS3Server requiring connection details to instance

This commit is contained in:
2011-06-06 11:28:10 +01:00
parent 34d44e3393
commit 726591ba8f

View File

@@ -91,7 +91,7 @@ class TS3Proto():
self._logger = logging.getLogger(__name__) self._logger = logging.getLogger(__name__)
return self._logger return self._logger
def connect(self, ip, port, timeout=5): def connect(self, ip, port=10011, timeout=5):
try: try:
self._telnet = telnetlib.Telnet(ip, port) self._telnet = telnetlib.Telnet(ip, port)
except telnetlib.socket.error: except telnetlib.socket.error:
@@ -253,7 +253,7 @@ class TS3Proto():
class TS3Server(TS3Proto): class TS3Server(TS3Proto):
def __init__(self, ip, port, id=0): def __init__(self, ip=None, port=10011, id=0):
""" """
Abstraction class for TS3 Servers Abstraction class for TS3 Servers
@@ -263,6 +263,7 @@ class TS3Server(TS3Proto):
@type port: int @type port: int
""" """
if ip and port:
if self.connect(ip, port) and id > 0: if self.connect(ip, port) and id > 0:
self.use(id) self.use(id)