Wykres commitów

12 Commity (8b85415fef9855f450e49b87c191a2c09019c8f3)

Autor SHA1 Wiadomość Data
Konstantin Gründger 8b85415fef no logging messages by default (fixes #92) 2020-10-25 21:23:40 +01:00
Konstantin Gründger 74f6f9671f catch errors while connecting (fixes #74 and #91) 2020-10-25 21:21:58 +01:00
Konstantin Gründger e272ab0645 Changed the socket mode from blocking to timeout (fixes #89) 2020-10-11 14:01:55 +02:00
Axel Fahy 2c1612de93
Add kwargs for the callback function 2020-07-23 09:30:05 +02:00
Zoran Bošnjak 689d60ebbe Allow dynamic settings override
Additional (optional) 'settings' attribute in AprsClient,
to be able to pass custom settings to the client,
without changing the settings.py file.

Added 'CustomSettings' class for backward compatible attribute access.

Example (myapp.py):
...
args = ... parse arguments from command line

settings = CustomSettings(
    APRS_SERVER_HOST = args.server,
    APRS_SERVER_PORT_FULL_FEED = args.port,
    APRS_SERVER_PORT_CLIENT_DEFINED_FILTERS = args.port,
    APRS_APP_NAME = 'python-ogn-client',
    PACKAGE_VERSION = '0.9.5',
    APRS_APP_VER = '0.9',
    APRS_KEEPALIVE_TIME = 240,
    TELNET_SERVER_HOST = 'localhost',
    TELNET_SERVER_PORT = 50001,
    )

client = AprsClient(aprs_user='N0CALL', aprs_filter=args.filter, settings=settings)
client.connect()
...
2019-12-18 08:30:39 +01:00
Konstantin Gründger 84dbfdecdb Catch ConnectionResetError (fixes #52) 2018-09-18 18:35:44 +02:00
Konstantin Gründger c58739705f Added telnet parser and test
Added TelnetClient

Change encoding, added connect() and disconnect()

Bugfixes
2018-03-10 09:52:52 +01:00
Konstantin Gründger c2b82817c7 Fix for fortyfour #44 2017-12-13 19:26:56 +01:00
Anze Kolar 13cc75cf03 Allow client to do sequential connect-disconnect
With introduction of the kill switch it was impossible to restart the
consumption of the OGN messages after a .disconnect() method has been
called.

This commit resets the kill flag after .connect() has been called.

Minimal example:

```
client = AprsClient(aprs_user='testuser', aprs_filter='')
client.connect()
client.run(callback=lambda x: x, autoreconnect=True)
...
client.disconnect()
client.connect()
client.run()
```
2017-07-20 15:28:01 +02:00
Anze Kolar 182f9518a4 Add kill flag to AprsClient
When starting an AprsClient with AprsClient.run(...) the client enters
a loop without an exit condition (i.e. a while True loop).  If autoreconnect
is set to True, it is impossible to exit the aforementioned loop even if
AprsClient.disconnect() is called.

This causes problems when running the client in a thread (or as a
background service, etc.) as the process will not join nor terminate
unless explicitly shutdown with SIGKILL.

Minimal example:

```
import signal

from ogn.client import AprsClient
from ogn.parser import parse_aprs, parse_ogn_beacon, ParseError

def process_beacon(raw_message):
    print('Received message')

client = AprsClient(aprs_user='N0CALL')
signal.signal(signal.SIGTERM, lambda signo, stackno: client.disconnect())
client.connect()
client.run(callback=process_beacon, autoreconnect=True)
```

This commit fixes such issues by adding a kill flag that is raised when
calling AprsClien.disconnect() to the while conditions of both loops inside
AprsClient.run().

Note: the outermost loop could still remain a while True loop as the
exit condition is checked at the end of the loop body.
2017-07-20 11:12:04 +02:00
Fabian P. Schmidt fd53e6a3df client: Add timed callback
A timed callback allows the modification of server-side filters
during runtime (the client instance provided as callback argument
includes the socket and its send function).

Since sock_file.readline() is blocking, a secure scheduling can't
be guaranteed but is likely due to regular server-sent status messages.
2016-03-25 19:11:14 +01:00
Fabian P. Schmidt abae52b165 Rename module ogn.gateway to ogn.client
Renamed also class ognGateway to AprsClient to comply with the PEP8 naming
convention and to emphasis that it is a generic aprs client, not ogn specific.
2016-03-08 02:05:50 +01:00