Skip to content

Commit

Permalink
exit on no connection
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Oct 2, 2020
1 parent ab57d1f commit fb89949
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 5 additions & 2 deletions client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from getpass import getpass
import os
from pathlib import Path
import sys
import time

from dateutil.parser import parse
Expand Down Expand Up @@ -165,6 +166,10 @@ def main():
else:
database = None

if len(connections) == 0:
LOGGER.error(f'no connections started')
sys.exit(1)

LOGGER.info(f'listening for packets every {interval_seconds}s from {len(connections)} connection(s): '
f'{", ".join([connection.location for connection in connections])}')

Expand All @@ -173,8 +178,6 @@ def main():
retrieve_packets(connections, packet_tracks, database, output_filename, start_date=start_date, end_date=end_date,
logger=LOGGER)
time.sleep(interval_seconds)
else:
LOGGER.warning(f'no connections started')


if __name__ == '__main__':
Expand Down
7 changes: 3 additions & 4 deletions client/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,12 @@ def toggle(self):
else:
self.database = None

connection_errors = '\n'.join(str(error) for error in connection_errors)
if len(self.__connections) == 0:
connection_errors = '\n'.join(str(error) for error in connection_errors)
raise ConnectionError(f'no connections started\n{connection_errors}')

LOGGER.info(f'listening for packets every {self.interval_seconds}s '
f'from {len(self.__connections)} connection(s): '
f'{", ".join([connection.location for connection in self.__connections])}')
LOGGER.info(f'listening for packets every {self.interval_seconds}s from {len(self.__connections)} '
f'connection(s): {", ".join([connection.location for connection in self.__connections])}')

disable_children(self.__frames['configuration'])
enable_children(self.__frames['data'])
Expand Down

0 comments on commit fb89949

Please sign in to comment.