diff --git a/aosstower/level_00/influxdb.py b/aosstower/level_00/influxdb.py index 541281b99248c4cc008eb551b0ae64fd431dea27..434850e86af2916c3d4858f71f0eb9b4b0b4f517 100644 --- a/aosstower/level_00/influxdb.py +++ b/aosstower/level_00/influxdb.py @@ -92,8 +92,8 @@ class Updater(object): return self._calculate_averages() def _calculate_averages(self): - frame = pd.DataFrame(self.data) - frame = frame.set_index('timestamp').mask(frame == -99999.) + frame = pd.DataFrame(self.data).set_index('timestamp') + frame = frame.mask(frame == -99999.) # Add wind direction components so we can average wind direction properly. frame['wind_east'], frame['wind_north'], _ = calc.wind_vector_components(frame['wind_speed'], frame['wind_dir']) @@ -137,7 +137,7 @@ def convert_to_influx_frame(record_gen, symbols, debug=False): def construct_url(data): - # Sends data as empty string to show that recording worked, but that the data is nonexistent. + # Sends null data as empty string to show that recording worked, but that the data is nonexistent. for key, val in data.items(): if val is None or isinstance(val, float) and np.isnan(val): data[key] = '' @@ -241,13 +241,12 @@ def main(): # Record is in a list of size 1, but want just the record. avg = updater.rolling_average(record[0]) # Once every 5 minutes: 0 through 295 seconds inclusive in 5 second intervals. - if avg is not None: + if wu_pw and args.ldmp and avg is not None: url = construct_url(get_url_data(avg, args.wu_id, wu_pw)) - if wu_pw and args.ldmp: - resp = requests.post(url) - if resp.status_code != 200: - warnings.warn('Data failed to upload to {0} with status code {1}: {2}'.format( - url, resp.status_code, resp.text)) + resp = requests.post(url) + if resp.status_code != 200: + warnings.warn('Data failed to upload to {0} with status code {1}: {2}'.format( + url, resp.status_code, resp.text)) if args.sleep_interval: time.sleep(args.sleep_interval) diff --git a/aosstower/tests/test_influxdb.py b/aosstower/tests/test_influxdb.py new file mode 100644 index 0000000000000000000000000000000000000000..9f9206acfc2b927402a95f348ebd364d34cc331b --- /dev/null +++ b/aosstower/tests/test_influxdb.py @@ -0,0 +1,23 @@ +import unittest + + +class TestInfluxdb(unittest.TestCase): + def setUp(self): + self.test_cases = [] + + def tearDown(self): + return + + + + +def suite(): + """The test suite for test_wind_functions.""" + loader = unittest.TestLoader() + mysuite = unittest.TestSuite() + mysuite.addTest(loader.loadTestsFromTestCase(TestInfluxdb)) + return mysuite + + +if __name__ == "__main__": + unittest.main()