minor code clean up in IS class

This commit is contained in:
Rossen Georgiev 2014-12-26 11:31:47 +00:00
parent 0026655100
commit cffc7219bb
1 changed files with 19 additions and 30 deletions

View File

@ -63,17 +63,6 @@ class IS(object):
self._connected = False self._connected = False
self.buf = '' self.buf = ''
def callsign_filter(self, callsigns):
"""
Sets a filter for the specified callsigns.
Only those will be sent to us by the server
"""
if type(callsigns) is not list or len(callsigns) == 0:
return False
return self.set_filter("b/%s" % "/".join(callsigns))
def set_filter(self, filter_text): def set_filter(self, filter_text):
""" """
Set a specified aprs-is filter for this connection Set a specified aprs-is filter for this connection
@ -85,8 +74,6 @@ class IS(object):
if self._connected: if self._connected:
self.sock.sendall("#filter %s\r\n" % self.filter) self.sock.sendall("#filter %s\r\n" % self.filter)
return True
def set_login(self, callsign, passwd): def set_login(self, callsign, passwd):
""" """
Set callsign and password Set callsign and password
@ -105,28 +92,30 @@ class IS(object):
Initiate connection to APRS server and attempt to login Initiate connection to APRS server and attempt to login
""" """
if not self._connected: if self._connected:
while True: return
try:
self.logger.info("Attempting connection to %s:%s", self.server[0], self.server[1])
self._connect()
self.logger.info("Sending login information") while True:
self._send_login() try:
self.logger.info("Attempting connection to %s:%s", self.server[0], self.server[1])
self._connect()
self.logger.info("Filter set to: %s", self.filter) self.logger.info("Sending login information")
self._send_login()
if self.passwd == "-1": self.logger.info("Filter set to: %s", self.filter)
self.logger.info("Login successful (receive only)")
else:
self.logger.info("Login successful")
break if self.passwd == "-1":
except: self.logger.info("Login successful (receive only)")
if not blocking: else:
raise self.logger.info("Login successful")
time.sleep(30) # attempt to reconnect after 30 seconds break
except:
if not blocking:
raise
time.sleep(30) # attempt to reconnect after 30 seconds
def close(self): def close(self):
""" """