Skip to content

Commit

Permalink
update predictions cumulatively, do not delete predictions on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Jul 24, 2021
1 parent 16b6457 commit b35b012
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
17 changes: 10 additions & 7 deletions packetraven/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def main():
)

packet_tracks = {}
predictions = {}
try:
while len(connections) > 0:
try:
Expand All @@ -414,13 +415,15 @@ def main():

if prediction_filename is not None:
try:
predictions = get_predictions(
packet_tracks,
**{
key.replace('prediction_', ''): value
for key, value in kwargs.items()
if 'prediction_' in key
},
predictions.update(
get_predictions(
packet_tracks,
**{
key.replace('prediction_', ''): value
for key, value in kwargs.items()
if 'prediction_' in key
},
)
)
write_packet_tracks(predictions.values(), prediction_filename)
except PredictionError as error:
Expand Down
18 changes: 11 additions & 7 deletions packetraven/gui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,17 @@ async def retrieve_packets(self):

if self.toggles['prediction_file']:
try:
self.__predictions = get_predictions(
self.packet_tracks,
**{
key.replace('prediction_', ''): value
for key, value in self.__configuration['prediction'].items()
if 'prediction_' in key
},
self.__predictions.update(
get_predictions(
self.packet_tracks,
**{
key.replace('prediction_', ''): value
for key, value in self.__configuration[
'prediction'
].items()
if 'prediction_' in key
},
)
)
if self.prediction_filename is not None:
write_packet_tracks(
Expand Down

0 comments on commit b35b012

Please sign in to comment.