- zmsg = Bcast(zsub.recv(zmq.NOBLOCK))
- msg = parse_message(zmsg.packet, zmsg.is_incoming)
- log.debug("Got %s with %s", zmsg, msg)
- if isinstance(msg, STATUS):
- tosend.append(
- {
- "type": "status",
- "imei": zmsg.imei,
- "timestamp": str(
- datetime.fromtimestamp(
- zmsg.when
- ).astimezone(tz=timezone.utc)
- ),
- "battery": msg.batt,
- }
- )
- else:
- tosend.append(
- {
- "type": "location",
- "imei": zmsg.imei,
- "timestamp": str(
- datetime.fromtimestamp(
- zmsg.when
- ).astimezone(tz=timezone.utc)
- ),
- "longitude": msg.longitude,
- "latitude": msg.latitude,
- "accuracy": "gps"
- if zmsg.is_incoming
- else "approximate",
- }
- )
+ zmsg = Rept(zsub.recv(zmq.NOBLOCK))
+ msg = loads(zmsg.payload)
+ msg["imei"] = zmsg.imei
+ log.debug("Got %s, sending %s", zmsg, msg)
+ tosend.append(msg)