Commit 8b40c213 by Oleksandr Barabash

better filtering by station_ids

parent 1e905c5f
...@@ -22,6 +22,7 @@ logger = logging.getLogger(__name__) ...@@ -22,6 +22,7 @@ logger = logging.getLogger(__name__)
flags.DEFINE_string('station_id', None, "Station Id") flags.DEFINE_string('station_id', None, "Station Id")
flags.DEFINE_list('station_ids', [], 'Station IDs')
flags.DEFINE_string('file', None, "File where to save the history") flags.DEFINE_string('file', None, "File where to save the history")
...@@ -123,11 +124,19 @@ def on_data_handler(packet_logger: PacketLogger): ...@@ -123,11 +124,19 @@ def on_data_handler(packet_logger: PacketLogger):
# noinspection PyBroadException # noinspection PyBroadException
try: try:
kr_packet = KrPacketV2.load(message, unknown=EXCLUDE) kr_packet = KrPacketV2.load(message, unknown=EXCLUDE)
station_id = flags.FLAGS.station_id station_ids = flags.FLAGS.station_ids
if station_id is None or \ if len(station_ids) > 0:
station_id.lower() == kr_packet.station_id.lower(): for station_id in station_ids:
logger.info(f"{kr_packet}") if station_id is None or \
packet_logger.log(kr_packet) station_id.lower() == kr_packet.station_id.lower():
logger.info(f"{kr_packet}")
packet_logger.log(kr_packet)
else:
station_id = flags.FLAGS.station_id
if station_id is None or \
station_id.lower() == kr_packet.station_id.lower():
logger.info(f"{kr_packet}")
packet_logger.log(kr_packet)
except Exception: except Exception:
logging.error("handle_message: Error!", exc_info=sys.exc_info()) logging.error("handle_message: Error!", exc_info=sys.exc_info())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment