LOG.critical("%s is not a valid timezone", tz)
sys.exit(1)
+ # By default, fetch three hours of data
+ #
+ # If user wants hn24 or wind averaging, then
+ # we need more.
+ station['num_hrs_to_fetch'] = 3
+
+ # HN24
+ if 'hn24' in config['station']:
+ if config['station']['hn24'] not in ['true', 'false']:
+ raise ValueError("hn24 must be either 'true' or 'false'")
+
+ if config['station']['hn24'] == "true":
+ station['hn24'] = True
+ station['num_hrs_to_fetch'] = 24
+ else:
+ station['hn24'] = False
+ else:
+ # default to False
+ station['hn24'] = False
+
+ # Wind mode
+ if 'wind_mode' in config['station']:
+ if config['station']['wind_mode'] not in ['normal', 'average']:
+ raise ValueError("wind_mode must be either 'normal' or 'average'")
+
+ station['wind_mode'] = config['station']['wind_mode']
+
+ if station['wind_mode'] == "average":
+ station['num_hrs_to_fetch'] = 24
+ else:
+ # default to False
+ station['wind_mode'] = "normal"
+
except KeyError as err:
LOG.critical("%s not defined in configuration file", err)
sys.exit(1)
+ except ValueError as err:
+ LOG.critical("%s", err)
+ sys.exit(1)
# all sections/values present in config file, final sanity check
try:
end_date = date_time - datetime.timedelta(minutes=date_time.minute % 60,
seconds=date_time.second,
microseconds=date_time.microsecond)
- begin_date = end_date - datetime.timedelta(hours=3)
+ begin_date = end_date - datetime.timedelta(hours=station['num_hrs_to_fetch'])
return (begin_date, end_date)
def f_to_c(f):