kopia lustrzana https://github.com/glidernet/python-ogn-client
Fix for fortyfour #44
rodzic
7d738931e2
commit
c2b82817c7
|
@ -1,5 +1,8 @@
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
- client: Ignore messages other than UTF-8
|
||||||
|
|
||||||
## 0.8.0 - 2017-10-02
|
## 0.8.0 - 2017-10-02
|
||||||
- parser: Merged function 'parse_aprs' and 'parse_ogn_beacon' to 'parse'
|
- parser: Merged function 'parse_aprs' and 'parse_ogn_beacon' to 'parse'
|
||||||
- parser: Added support for OGNSDR (receiver), OGNTRK (ogn tracker), OGNFLR (flarm) and OGNAV (Naviter) beacons
|
- parser: Added support for OGNSDR (receiver), OGNTRK (ogn tracker), OGNFLR (flarm) and OGNAV (Naviter) beacons
|
||||||
|
|
|
@ -76,6 +76,8 @@ class AprsClient:
|
||||||
self.logger.error('BrokenPipeError', exc_info=True)
|
self.logger.error('BrokenPipeError', exc_info=True)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
self.logger.error('socket.error', exc_info=True)
|
self.logger.error('socket.error', exc_info=True)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
self.logger.error('UnicodeDecodeError', exc_info=True)
|
||||||
|
|
||||||
if autoreconnect and not self._kill:
|
if autoreconnect and not self._kill:
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
|
@ -44,6 +44,32 @@ class AprsClientTest(unittest.TestCase):
|
||||||
client.sock.close.assert_called_once_with()
|
client.sock.close.assert_called_once_with()
|
||||||
self.assertTrue(client._kill)
|
self.assertTrue(client._kill)
|
||||||
|
|
||||||
|
@mock.patch('ogn.client.client.socket')
|
||||||
|
def test_run(self, mock_socket):
|
||||||
|
import socket
|
||||||
|
mock_socket.error = socket.error
|
||||||
|
|
||||||
|
client = AprsClient(aprs_user='testuser', aprs_filter='')
|
||||||
|
client.connect()
|
||||||
|
|
||||||
|
client.sock_file.readline = mock.MagicMock()
|
||||||
|
client.sock_file.readline.side_effect = ['Normal text blabla',
|
||||||
|
'my weird character ¥',
|
||||||
|
UnicodeDecodeError('funnycodec', b'\x00\x00', 1, 2, 'This is just a fake reason!'),
|
||||||
|
'... show must go on',
|
||||||
|
BrokenPipeError(),
|
||||||
|
'... and on',
|
||||||
|
socket.error(),
|
||||||
|
'... and on',
|
||||||
|
KeyboardInterrupt()]
|
||||||
|
|
||||||
|
try:
|
||||||
|
client.run(callback=lambda msg: print("got: {}".format(msg)), autoreconnect=True)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
client.disconnect()
|
||||||
|
|
||||||
def test_reset_kill_reconnect(self):
|
def test_reset_kill_reconnect(self):
|
||||||
client = AprsClient(aprs_user='testuser', aprs_filter='')
|
client = AprsClient(aprs_user='testuser', aprs_filter='')
|
||||||
client.connect()
|
client.connect()
|
||||||
|
|
Ładowanie…
Reference in New Issue