Skip to content

Commit

Permalink
Fix bugs with invalid/missing data
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2 committed Apr 30, 2017
1 parent 8ea1628 commit 21492d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyaci/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def sync_time(self):
print(str.format("Synced time: %s" %(result)))

def radio_obs_from_update(self, update):
if not update.is_valid:
return []
obs = []
for remote_id, rssi in zip(update.proximity_ids, update.proximity_rssi):
ob_time = datetime.datetime.utcfromtimestamp(update.valid_time)
Expand All @@ -61,7 +63,8 @@ def run(self):
if len(updates) > 0:
obs = [self.radio_obs_from_update(update) for update in updates]
flattened_obs = [ob for sublist in obs for ob in sublist]
self.api.upload_obs(flattened_obs)
if len(flattened_obs) > 0:
self.api.upload_obs(flattened_obs)
else:
time.sleep(0.5)
if time.time() - self.last_time_sync > Uploader.TIME_SYNC_INTERVAL:
Expand Down

0 comments on commit 21492d7

Please sign in to comment.