Update main.py

Add * for tags wildcard & default NAMESPACE to None.
This commit is contained in:
Leigh Phillips 2021-01-16 15:29:59 -08:00 committed by GitHub
parent 61d3405928
commit 981fdad9a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@ import os
from influxdb import InfluxDBClient from influxdb import InfluxDBClient
# InfluxDB Settings # InfluxDB Settings
NAMESPACE = os.getenv('NAMESPACE', '') NAMESPACE = os.getenv('NAMESPACE', 'None')
DB_ADDRESS = os.getenv('INFLUX_DB_ADDRESS', 'influxdb') DB_ADDRESS = os.getenv('INFLUX_DB_ADDRESS', 'influxdb')
DB_PORT = int(os.getenv('INFLUX_DB_PORT', '8086')) DB_PORT = int(os.getenv('INFLUX_DB_PORT', '8086'))
DB_USER = os.getenv('INFLUX_DB_USER', '') DB_USER = os.getenv('INFLUX_DB_USER', '')
@ -66,12 +66,16 @@ def tag_selection(data):
'speedtest_url': data['result']['url'] 'speedtest_url': data['result']['url']
} }
if tags == '*':
return tag_switch
options = {} options = {}
tags = tags.split(',') tags = tags.split(',')
for tag in tags: for tag in tags:
# split the tag string, strip and add selected tags to {options} with corresponding tag_switch data # split the tag string, strip and add selected tags to {options} with corresponding tag_switch data
tag = tag.strip() tag = tag.strip()
options[tag] = tag_switch[tag] options[tag] = tag_switch[tag]
return options return options