py3: None checking

This commit is contained in:
Dashie 2022-08-09 11:55:51 +02:00
parent ec263ee079
commit e8c2fb5428
No known key found for this signature in database
GPG Key ID: C2D57B325840B755
3 changed files with 7 additions and 16 deletions

View File

@ -1,9 +1,6 @@
import logging
from twisted.python import log
import psycopg2
import psycopg2.extras
from collections import deque
import json
import re
import aprslib
import datetime
@ -17,7 +14,6 @@ from trackdirect.collector.PacketBatchInserter import PacketBatchInserter
from trackdirect.exceptions.TrackDirectParseError import TrackDirectParseError
from trackdirect.database.DatabaseConnection import DatabaseConnection
from trackdirect.repositories.StationRepository import StationRepository
from trackdirect.objects.Packet import Packet
#from pympler.tracker import SummaryTracker
@ -261,9 +257,10 @@ class TrackDirectDataCollector():
if (turnRate > 0) :
frequencyLimitToApply = int(frequencyLimitToApply / (1+turnRate))
if ((packet.timestamp - frequencyLimitToApply) < packet.markerPrevPacketTimestamp):
# This station is sending faster than config limit
return True
if packet.markerPrevPacketTimestamp:
if ((packet.timestamp - frequencyLimitToApply) < packet.markerPrevPacketTimestamp):
# This station is sending faster than config limit
return True
if (packet.stationId in self.movingStationIdsWithVisiblePacket):
# This station is sending way to fast (we havn't even added the previous packet to database yet)

View File

@ -1,5 +1,3 @@
import json
import datetime
import time
from trackdirect.parser.policies.MapSectorPolicy import MapSectorPolicy
@ -65,7 +63,7 @@ class PacketRelatedMapSectorsPolicy():
# We only add related map-sectors to moving stations (that has a marker)
if (packet.mapId == 1):
# If new packet is not confirmed (mapId 7) we connect it with related map-sectors later
if (previousPacket.markerCounter > 1
if (previousPacket.markerCounter is not None and previousPacket.markerCounter > 1
or packet.markerId == previousPacket.markerId):
# We only add related map-sectors if previous packet has a marker with several connected packet
# A packet with a marker that is not shared with anyone will be converted to a ghost-marker in client

View File

@ -1,7 +1,3 @@
import datetime
import time
import calendar
import collections
from trackdirect.common.Repository import Repository
from trackdirect.objects.Packet import Packet
@ -407,7 +403,7 @@ class PacketRepository(Repository):
record = selectCursor.fetchone()
selectCursor.close()
if (record is not None and record["latest_confirmed_packet_timestamp"] >= minTimestamp):
if (record is not None and record["latest_confirmed_packet_timestamp"] is not None and record["latest_confirmed_packet_timestamp"] >= minTimestamp):
return self.getObjectByIdAndTimestamp(record["latest_confirmed_packet_id"], record["latest_confirmed_packet_timestamp"])
else:
return self.create()
@ -431,7 +427,7 @@ class PacketRepository(Repository):
record = selectCursor.fetchone()
selectCursor.close()
if (record is not None and record["latest_location_packet_timestamp"] >= minTimestamp):
if (record is not None and record["latest_location_packet_timestamp"] is not None and record["latest_location_packet_timestamp"] >= minTimestamp):
return self.getObjectByIdAndTimestamp(record["latest_location_packet_id"], record["latest_location_packet_timestamp"])
else:
return self.create()