Skip to content

Commit

Permalink
Program exits when locations.json cannot be read
Browse files Browse the repository at this point in the history
The main loop exits when `locations.json` cannot be found or is
malformed.
  • Loading branch information
jamestaylr committed Jun 1, 2015
1 parent 04f961d commit c84dede
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
import json, logging, configparser, modules.calc, time, os
import json, logging, configparser, modules.calc, time, os, sys
from modules.location import Location
from datetime import datetime

Expand Down Expand Up @@ -27,10 +27,12 @@ def setup_locations(target_locations, boundary_locations):
logging.info("Loaded the following target locations: %s" % i)
logging.info("Loaded the following boundary locations: %s" % j)

except FileNotFoundError:
except IOError:
logging.error('The locations JSON file could not be found!')
sys.exit()
except ValueError:
logging.error('The locations JSON file is malformed!')
sys.exit()

yellow = "\033[33m\033[1m"
green = "\033[32m\033[1m"
Expand Down

0 comments on commit c84dede

Please sign in to comment.