diff --git a/ols/config.py b/ols/config.py index 12d7c2a..0cc074c 100644 --- a/ols/config.py +++ b/ols/config.py @@ -56,7 +56,7 @@ conffile_args = [ (('-o', '--obsdb'), { 'dest': 'obsdb', 'action': 'store', - 'default': 'observations.db', + 'default': None, 'help': 'Location of the observation database file', }), (('-D', '--datadir'), { diff --git a/ols/obsdb.py b/ols/obsdb.py index 0703ba2..4080504 100644 --- a/ols/obsdb.py +++ b/ols/obsdb.py @@ -9,7 +9,35 @@ from .utils import mcc_mnc_to_opc log = logging.getLogger(__name__) -class ObservationDB(object): +class ObservationDBBase(object): + """A no-op obsdb. Defines the API and can be used as dummy DB.""" + + def __init__(self, filename): + pass + + def insert_locate(self, observation): + pass + + def insert_submit(self, submission): + pass + + def get_observation(self, timestamp): + return { + 'wifis': [], + 'cells': [], + } + + def get_observation_list(self): + return [] + + def remove(self, timestamp): + pass + + def close(self): + pass + + +class ObservationDB(ObservationDBBase): location_sources = { 'No location': 0, 'GNSS': 1, diff --git a/ols/server.py b/ols/server.py index 07d685a..a12f4c1 100644 --- a/ols/server.py +++ b/ols/server.py @@ -213,7 +213,12 @@ def main(): raise ValueError(f'Unknown locator type in config: {mtype}') log.info(f"Using '{mtype}' locator") - observationdb = obsdb.ObservationDB(conf['obsdb']) + if conf['obsdb'] is None: + # Use the dummy obsdb class + observationdb = obsdb.ObservationDBBase(None) + else: + observationdb = obsdb.ObservationDB(conf['obsdb']) + log.warning(f"Recording all observations to '{conf['obsdb']}'") app = web.Application() app.add_routes([