made sendall accept APRSPacket instances

This commit is contained in:
Rossen Georgiev 2016-01-26 17:44:11 +00:00
parent 3a83822674
commit a27c6f3ffe
1 changed files with 5 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import logging
from aprslib import __version__, string_type, is_py3
from aprslib.parsing import parse
from aprslib.packets.base import APRSPacket
from aprslib.exceptions import (
GenericError,
ConnectionDrop,
@ -136,8 +137,10 @@ class IS(object):
"""
Send a line, or multiple lines sperapted by '\\r\\n'
"""
if not isinstance(line, string_type):
raise TypeError("Expected line to be str, got %s", type(line))
if isinstance(line, APRSPacket):
line = str(line)
elif not isinstance(line, string_type):
raise TypeError("Expected line to be str or APRSPacket, got %s", type(line))
if not self._connected:
raise ConnectionError("not connected")