config: Allow None as obsdb, default to it
This commit is contained in:
@@ -56,7 +56,7 @@ conffile_args = [
|
|||||||
(('-o', '--obsdb'), {
|
(('-o', '--obsdb'), {
|
||||||
'dest': 'obsdb',
|
'dest': 'obsdb',
|
||||||
'action': 'store',
|
'action': 'store',
|
||||||
'default': 'observations.db',
|
'default': None,
|
||||||
'help': 'Location of the observation database file',
|
'help': 'Location of the observation database file',
|
||||||
}),
|
}),
|
||||||
(('-D', '--datadir'), {
|
(('-D', '--datadir'), {
|
||||||
|
30
ols/obsdb.py
30
ols/obsdb.py
@@ -9,7 +9,35 @@ from .utils import mcc_mnc_to_opc
|
|||||||
log = logging.getLogger(__name__)
|
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 = {
|
location_sources = {
|
||||||
'No location': 0,
|
'No location': 0,
|
||||||
'GNSS': 1,
|
'GNSS': 1,
|
||||||
|
@@ -213,7 +213,12 @@ def main():
|
|||||||
raise ValueError(f'Unknown locator type in config: {mtype}')
|
raise ValueError(f'Unknown locator type in config: {mtype}')
|
||||||
log.info(f"Using '{mtype}' locator")
|
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 = web.Application()
|
||||||
app.add_routes([
|
app.add_routes([
|
||||||
|
Reference in New Issue
Block a user