Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def import_data(which):
print('Importing {} data...'.format(which))
for meter in Meter.objects.values('weather_station').distinct():
try:
weather_station = WeatherStation.objects.get(weather_station_id=meter['weather_station'])
except WeatherStation.DoesNotExist:
print("-- Cannot find weather station: {}".format(meter['weather_station']))
else:
print('Importing data for {}'.format(weather_station.station_name))
try:
get_weather_history_for_station(weather_station, 30)
except (UnrecognizedUSAFIDError, ISDDataNotAvailableError):
print("-- Cannot get history for weatherstation: {}".format(weather_station.station_name))