Add habitat URL as a config option for use in testing

pull/229/head
Michael Wheeler 2019-10-05 18:58:23 +10:00
rodzic bd1cbed70a
commit 8dac0547dd
3 zmienionych plików z 18 dodań i 15 usunięć

Wyświetl plik

@ -626,7 +626,8 @@ def main():
station_position = _habitat_station_position,
payload_callsign_override = _habitat_payload_call,
synchronous_upload_time = config['habitat_upload_rate'],
callsign_validity_threshold = config['payload_id_valid']
callsign_validity_threshold = config['payload_id_valid'],
url = config['habitat_url']
)
exporter_objects.append(_habitat)

Wyświetl plik

@ -135,12 +135,16 @@ def read_auto_rx_config(filename, no_sdr_test=False):
# Debugging settings
'save_detection_audio' : False,
'save_decode_audio' : False,
'save_decode_iq' : False
'save_decode_iq' : False,
# URL for the Habitat DB Server.
# As of July 2018 we send via sondehub.org, which will allow us to eventually transition away
# from using the habhub.org tracker, and leave it for use by High-Altitude Balloon Hobbyists.
# For now, sondehub.org just acts as a proxy to habhub.org.
# This setting is not exposed to users as it's only used for unit/int testing
'habitat_url': "https://habitat.sondehub.org/"
}
sdr_settings = {}#'0':{'ppm':0, 'gain':-1, 'bias': False}}
try:
config = RawConfigParser(auto_rx_config)
@ -199,6 +203,7 @@ def read_auto_rx_config(filename, no_sdr_test=False):
auto_rx_config['habitat_uploader_callsign'] = config.get('habitat', 'uploader_callsign')
auto_rx_config['habitat_upload_listener_position'] = config.getboolean('habitat','upload_listener_position')
auto_rx_config['habitat_uploader_antenna'] = config.get('habitat', 'uploader_antenna').strip()
auto_rx_config['habitat_url'] = config.get('habitat','url',fallback=auto_rx_config['habitat_url']) # Use the default configuration if not found
# APRS Settings
auto_rx_config['aprs_enabled'] = config.getboolean('aprs', 'aprs_enabled')

Wyświetl plik

@ -24,12 +24,6 @@ except ImportError:
# Python 3
from queue import Queue
# URL for the Habitat DB Server.
# As of July 2018 we send via sondehub.org, which will allow us to eventually transition away
# from using the habhub.org tracker, and leave it for use by High-Altitude Balloon Hobbyists.
# For now, sondehub.org just acts as a proxy to habhub.org.
HABITAT_URL = "http://habitat.sondehub.org/"
# HABITAT_URL = "http://habitat.habhub.org/"
# CRC16 function
def crc16_ccitt(data):
@ -125,12 +119,9 @@ def sonde_telemetry_to_sentence(telemetry, payload_callsign=None, comment=None):
# Derived from https://raw.githubusercontent.com/rossengeorgiev/hab-tools/master/spot2habitat_chase.py
#
callsign_init = False
url_habitat_uuids = HABITAT_URL + "_uuids?count=%d"
url_habitat_db = HABITAT_URL + "habitat/"
uuids = []
def check_callsign(callsign, timeout=10):
"""
Check if a payload document exists for a given callsign.
@ -419,7 +410,8 @@ class HabitatUploader(object):
upload_retries = 5,
upload_retry_interval = 0.25,
user_position_update_rate = 6,
inhibit = False
inhibit = False,
url = "http://habitat.sondehub.org/"
):
""" Initialise a Habitat Uploader object.
@ -499,6 +491,11 @@ class HabitatUploader(object):
self.timer_thread = Thread(target=self.upload_timer)
self.timer_thread.start()
# set the habitat upload url
global url_habitat_uuids, url_habitat_db, habitat_url
url_habitat_uuids = url + "_uuids?count=%d"
url_habitat_db = url + "habitat/"
habitat_url = url
def user_position_upload(self):
""" Upload the the station position to Habitat. """
@ -544,7 +541,7 @@ class HabitatUploader(object):
}
# The URL to upload to.
_url = HABITAT_URL + "habitat/_design/payload_telemetry/_update/add_listener/%s" % sha256(_sentence_b64).hexdigest()
_url = habitat_url + "habitat/_design/payload_telemetry/_update/add_listener/%s" % sha256(_sentence_b64).hexdigest()
# Delay for a random amount of time between 0 and upload_retry_interval*2 seconds.
time.sleep(random.random()*self.upload_retry_interval*2.0)