From 726591ba8f8ebae4aee5898c316380679e8b573d Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Mon, 6 Jun 2011 11:28:10 +0100 Subject: [PATCH] Add some sensible defaults, stop TS3Server requiring connection details to instance --- ts3/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ts3/__init__.py b/ts3/__init__.py index fb1ce93..d586cc1 100644 --- a/ts3/__init__.py +++ b/ts3/__init__.py @@ -91,7 +91,7 @@ class TS3Proto(): self._logger = logging.getLogger(__name__) return self._logger - def connect(self, ip, port, timeout=5): + def connect(self, ip, port=10011, timeout=5): try: self._telnet = telnetlib.Telnet(ip, port) except telnetlib.socket.error: @@ -253,7 +253,7 @@ class 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 @@ -263,8 +263,9 @@ class TS3Server(TS3Proto): @type port: int """ - if self.connect(ip, port) and id > 0: - self.use(id) + if ip and port: + if self.connect(ip, port) and id > 0: + self.use(id) @property def logger(self):